I’m afraid it’s not possible. Featured images are inserted using a CSS background property (see the FAQ) and, as far as I know, no lazy load plugin can deal with that.
Thread Starter
Lakjin
(@lakjin)
Is it possible to change the code so that CSS background property is not used?
Yes, it is. Go to includes/nelio-efi-main.php line 59, where the function nelioefi_get_html_thumbnail is defined:
function nelioefi_get_html_thumbnail( $id, $size = false, $attr = array() ) {
if ( uses_nelioefi( $id ) === false )
return false;
$image_url = nelioefi_get_thumbnail_src( $id );
// ...
if ( is_feed() ) {
$style = '';
if ( isset( $attr['style'] ) )
$style = 'style="' . $attr['style'] . '" ';
$html = sprintf( ...
} else {
$html = sprintf( ...
}
return $html;
}
Change this:
if ( is_feed() ) {
to this:
if ( true ) {
This way, the image will be inserted using the src attribute of an img tag, instead of a CSS background property.
Thread Starter
Lakjin
(@lakjin)
Thanks, worked well. Do you think you will add this as an option for the plugin in the future? This way this sticks when the plugin is updated.
Sure! I can add that as a setting.
Thread Starter
Lakjin
(@lakjin)
Great, thanks!
Another question. By default, your plugin automatically replaces featured images with external image, if there is an external image. Is there a function I can manually call to display external featured image?
What I’m looking to do is add a specific property to the img src tag to stop lazy load on specific images. However, I would need to manually call the external featured image to do that, because I don’t see any other way to selectively disable lazy load.
Our plugin includes a function called: nelioefi_get_thumbnail_src($post_id), which returns the URL of the external featured image used by the post $post_id, or false if no external feat. image is used. I hope this helps!