![Check out Enfold](https://kriesi.at/wp-content/themes/kriesi/images/banner-enfold.jpg)
-
AuthorPosts
-
August 31, 2022 at 9:22 am #1363314
Hello, we have a quite large site where the setting of lazy loading images is disabled (although it’s globlally enabled but we know now that this does not matter since the setting needs to be enabled on every image).
Since it’s a large site we don’t want to edit every single image on every page.
We tried to simply replace all strings in wp_posts and wp_post_meta but this did not work. Is there something more we need to consider we doing an bulk update of the lazy_loading option ?
Our SQL script
update wp_posts set post_content = REPLACE(post_content, "lazy_loading='disabled'", "lazy_loading='enabled'") where post_content like "%lazy_loading='disabled'%";
update wp_postmeta set meta_value = REPLACE(meta_value, "lazy_loading='disabled'", "lazy_loading='enabled'") where meta_value like "%lazy_loading='disabled'%" and meta_value not like "%a:%";
September 1, 2022 at 9:14 am #1363448Hey Leon,
Thank you for the inquiry.
Have you tried adding the wp_lazy_loading_enabled filter to disable lazy loading globally?
add_filter( 'wp_lazy_loading_enabled', '__return_false' );
You can also use this plugin.
// https://wordpress.org/plugins/disable-lazy-loading/
Best regards,
IsmaelSeptember 1, 2022 at 10:08 am #1363460September 2, 2022 at 8:04 am #1363569Hi,
Sorry for the confusion. The correct attribute in order to enable lazy loading is loading=”lazy” (https://developer.mozilla.org/en-US/docs/Web/Performance/Lazy_loading).
You may need to install a plugin for this because not all image entities in the database has the loading attribute by default (e.g shortcodes), so search and replace might not work as expected. Also, please note that WordPress automatically adds the loading attribute to images when they are retrieve using default functions such as wp_get_attachment_image or get_the_post_thumbnail.
// https://make.wordpress.org/core/2020/07/14/lazy-loading-images-in-5-5/
You can try one of the these plugins.
// https://wordpress.org/plugins/optimole-wp/
// https://wordpress.org/plugins/rocket-lazy-load/Best regards,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.