wp-media / rocket-lazy-load

Standalone LazyLoad plugin for WordPress (based on WP Rocket)
https://wordpress.org/plugins/rocket-lazy-load/
GNU General Public License v3.0
24 stars 13 forks source link

Plugin create divs within p-tags if wpautop() is active #121

Open mifrero opened 3 years ago

mifrero commented 3 years ago

Output source code:

Browser output for users:

<div .....>

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

jorgemartine00 commented 3 years ago

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; }

DahmaniAdame commented 3 years ago

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.

lkraav commented 3 years ago

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.