Support » Alpha/Beta/RC » lazy load iframes will break sites with ads

  • Resolved BlogAid

    (@blogaid)


    We need a super easy way to turn off lazy load of iframes in WP 5.7 as it will break sites where ads are placed by 3rd party ad agencies who use their own lazy load.

    The whole idea of lazy load of images and iframes was a good idea – a year ago. But now that most browsers do it natively and/or site owners have their own way of doing it, I think it’s a horribly bad idea for WP to turn it on by default with no easy way for non-techie site owners to be able to turn it off.

    We don’t want these site owners going into their code or having to add a plugin. There should be a checkbox in WP for every option like this that they add.

    I posted this concern on the WP 5.7 forum and got zero replies. I hope here is the correct place to post it.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Joy

    (@joyously)

    There is a filter you can use. And the attribute only applies to images or iframes that have both width and height.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Plugin Review Team Rep

    We need a super easy way to turn off lazy load of iframes in WP 5.7 as it will break sites where ads are placed by 3rd party ad agencies who use their own lazy load.

    This can be done:

    Lazy-loading iframes in 5.7

    Here is an example code snippet which would disable lazy-loading iframes that embed YouTube videos within post content:

    
    function skip_loading_lazy_youtube_iframes( $value, $iframe, $context ) {
        if ( 'the_content' === $context && false !== strpos( $iframe, 'youtube.com' ) {
            return false;
        }
        return $value;
    }
    add_filter(
        'wp_iframe_tag_add_loading_attr',
        'skip_loading_lazy_youtube_iframes',
        10,
        3
    );

    Change out youtube.com to whatever you use for ads 🙂

    https://make.wordpress.org/core/2020/07/14/lazy-loading-images-in-5-5/#customizing-lazy-loading has more details.

    Since this is not a support post, however, I’m closing it. There’s nothing wrong or broken in 5.7.

    Moderator James Huff

    (@macmanx)

    Volunteer Moderator

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘lazy load iframes will break sites with ads’ is closed to new replies.