Jump to content

RogerM

New Members
  • Posts

    1
  • Joined

  • Last visited

RogerM's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. 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?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.