wp-media / wp-rocket

Performance optimization plugin for WordPress
https://wp-rocket.me
GNU General Public License v2.0
701 stars 219 forks source link

Tags inserted between the <iframe> tag break the iframes lazyload feature #1346

Closed vmanthos closed 5 years ago

vmanthos commented 5 years ago

When there is a tag inserted between <iframe></iframe> the iframes lazyload feature breaks.

Doing the :

preg_match_all( '/<iframe.*\ssrc=["|\'](.+)["|\'].*(>\s*<\/iframe>)/iU', $html, $matches, PREG_SET_ORDER );

on this:

<iframe style="border: none;" src="https://snazzymaps.com/embed/12345" width="100%" height="300px"><span data-mce-type="bookmark" style="display: inline-block; width: 0px; overflow: hidden; line-height: 0;" class="mce_SELRES_start"></span></iframe>

produces this:

<iframe style="border: none;" src="about:blank" width="100%" height="300px">
    <span data-mce-type="bookmark" style="display: inline-block; width: 0px; overflow: hidden; line-height: 0;" class="mce_SELRES_start">
    </span data-rocket-lazyload="fitvidscompatible"data-lazy-src="https://snazzymaps.com/embed/12345">
</iframe>

breaking the lazyload of the iframe.

RegEx example: https://regex101.com/r/MZg0d8/1/

Related ticket: https://secure.helpscout.net/conversation/706786800/86043?folderId=2135277


The following part was added automatically:

<span data-mce-type="bookmark" style="display: inline-block; width: 0px; overflow: hidden; line-height: 0;" class="mce_SELRES_start"></span>

References

vmanthos commented 5 years ago

Another case: https://secure.helpscout.net/conversation/712138127/86959?folderId=2135277

ernee commented 5 years ago

Another case here: https://secure.helpscout.net/conversation/711946178/86928/?folderId=1391600 Customer said she used embed code from Google My Maps, so the extra <span> could be due to what Vasilis highlights.