I'm trying to prevent some images that are above the fold from being lazy loaded but I can't access the html of the images. Only the wrappers.
Is there any way to access plane HTML of Elementor Wordpress?
Thank you
I'm trying to prevent some images that are above the fold from being lazy loaded but I can't access the html of the images. Only the wrappers.
Is there any way to access plane HTML of Elementor Wordpress?
Thank you
To add a custom attribute to a specific Image Widget`s IMG tag follow the steps given below:
For example, if you are required not to lazy load selected images and want to add the attribute loading="eager" to the IMG tag,
1. Add the class eager in the Advanced tab of the Edit widget to the Image Widget you do not want to lazy load. Check the screenshot given below:
2. Add the code given below in the child theme's functions.php file
add_action( 'elementor/widget/render_content', function( $content, $widget ) {
if ( 'image' === $widget->get_name() ) {
$settings = $widget->get_settings();
$classes = $settings['_css_classes'];
if ( strpos( $classes, 'eager' ) !== false ) {
$content = str_replace( '<img', '<img loading="eager"', $content );
}
}
return $content;
}, 10, 2 );