Hi there guys!
I am at the moment trying to learn PHP as I want to get better at WordPress development and speed/performance optimization.
Right now I want to build a simple plugin (or just insert this code snippet directly into the function.php file) that allows me to preload all feature images from a blog and, at the same time, exclude these featured images from lazy loading.
This is what I got thus far...
// preloading feature images for blog posts
function featureimagepreload(){
if( is_single() ){
$featured_img_url = get_the_post_thumbnail_url(get_the_ID(),'full');
echo '<link rel="preload" as="image" href="'.$featured_img_url.'"/>';
}
}
add_action( 'wp_head', 'featureimagepreload');
Thoughts?