Problem: I love WP Rocket; I think it’s one of the best optimization plugins available. Their iframe and video optimization can make a significant difference in speed for pages that include videos as it creates an overlay, so the video doesn’t load until it’s clicked. However, in Elegant Theme‘s Extra theme, its video post format already includes an overlay. The WP Rocket lazyload disables Extra theme featured video. When you turn on WP Rocket lazyload, then the Extra featured video won’t work. This is likely true for Divi as well.
I could just turn off lazyload. However, I have other videos that use the YouTube block. Having the iframe and video lazyload turned on makes a significant difference in website speed for posts that include video.
Here’s what I did to disable the WP Rocket lazyload for the Extra video post format featured video:
WP Rocket offers a snippet to disable lazyloads based on patterns. 1080 was the only pattern I could find to exclude that actually worked.
If you try this snippet as always, place it in your functions.php, ideally in a child theme. And make sure to make a backup of your existing functions.php before making any changes.
Here’s the snippet:
/*disable lazyload for divi and extra video post format iframes*/
function rocket_lazyload_exclude_pattern( $pattern ) {
$pattern[] = '1080';
return $pattern;
}
add_filter( 'rocket_lazyload_iframe_excluded_patterns', 'rocket_lazyload_exclude_pattern' );
Hopefully, this can help your video format posts blast off again!
Did this work for you? Do you have any other suggestions to help with this issue?