rocket-lazy-load
rocket-lazy-load copied to clipboard
Plugin create divs within p-tags if wpautop() is active
Output source code:
Browser output for users:
This behaviour creates unnecessary paragraphs and if the paragraphs are formatted in CSS with padding/margin, for example, this creates unsightly empty blocks for the user in the browser.
Example: https://iphone-tricks.com/tutorial/4028-whatsapp-how-to-use-bold-italic-and-strikethrough-text
Ticket on WP Rocket inbox: https://secure.helpscout.net/conversation/1451726245/247022?folderId=2952229
client fixed the issue using the following snippet:
add_filter( 'the_content', 'removeParagraphsAroundIframes' ); function removeParagraphsAroundIframes( $content ) { $content = str_replace( [ '<p><iframe', '</iframe></p>' ], [ '<iframe', '</iframe>' ], $content ); return $content; }
It's similar to this one - https://github.com/wp-media/wp-rocket/issues/3716
A more efficient fix is to change our wrapper <div> to <span> with a display: block; property as mentioned on the issue (WP Rocket repo #3716).
This will avoid extensive search/replace.
All wpautop() stray p-tags are possibly related to everbug https://core.trac.wordpress.org/ticket/14050
Out of scientific interest, give this drop-in mu-plugin a shot https://core.trac.wordpress.org/attachment/ticket/14050/plugin.php
I'm still using it on all WP instances in my management.
With block-based content conversion, I think wpautop() deficiencies will eventually cease to be a problem, but for Classic mode the problem will persist basically forever.