Shortpixel uses the init
hook with a priority of 1
to call its output buffer function to rewrite the default img
tag to the picture
tag.
Meanwhile, WP Rocket uses the template_redirect
with a priority of 2
.
This means Shortpixel rewrite happens after WP Rocket rewrite, producing unexpected markup, and breaking lazyload.
Shortpixel also provides a solution based on WP hooks, and this one works well with our own buffering.
2 solutions here:
template_redirect
with a priority higher than 2
.Note from version doc proposal - "Remy noted that this was a little risky in terms of how it could produce issues, and so far has only produced 2 tickets. So we decided to leave it out of 3.3.4"
Just to add (I think this is the issue I've been hit with). For me Shortpixel AI (which adds Webp and a CDN rewrite to all images) just did nothing when WP Rocket Lazyload was enabled.
Shortpixel AI (Adaptive Images) includes Lazy Loading itself. All you have to do is switch the WP Rocket Lazy Load for images option off and Shortpixel AI starts to work. Maybe a 3rd option is to notify and disable WP Rocket lazy load when Shortpixel AI is detected as enabled?
i would like to suggest that Rocket WP allow the option to serve up WebP with the
Related ticket: https://secure.helpscout.net/conversation/1181425003/169514/
Most helpful comment
Just to add (I think this is the issue I've been hit with). For me Shortpixel AI (which adds Webp and a CDN rewrite to all images) just did nothing when WP Rocket Lazyload was enabled.
Shortpixel AI (Adaptive Images) includes Lazy Loading itself. All you have to do is switch the WP Rocket Lazy Load for images option off and Shortpixel AI starts to work. Maybe a 3rd option is to notify and disable WP Rocket lazy load when Shortpixel AI is detected as enabled?