Suggested change to get_image function
-
I made changes to the plugin on one of my sites, and suggest this change for the plugin itself.
in file: classes/functions.php around line 430 this code is present:
$class = $class ? ' class="'.$class.'" ' : ''; return '<img loading="lazy" '.$class.$alt.' src="'.wp_get_attachment_image_url( $attach_id, $size ).'" />';
My change is the following:
$class = $class ? ' class="'.$class.'" ' : ''; $srcset = wp_get_attachment_image_srcset( $attach_id ); return '<img srcset="'.esc_attr( $srcset ).' loading="lazy" '.$class.$alt.' src="'.wp_get_attachment_image_url( $attach_id, $size ).'" />';
What this does is adding srcset to the images, making a PageSpeed score higher and loadtimes faster.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Suggested change to get_image function’ is closed to new replies.