Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #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:%";
    #1363448

    Hey 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,
    Ismael

    #1363460

    Hello Ismael,

    thank you for the request.

    We want to globally enable the lazy loading feature :)

    • This reply was modified 2 years ago by Leon.
    • This reply was modified 2 years ago by Leon.
    #1363569

    Hi,

    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

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.