Lazy Images: Add jetpack-lazy-loaded-image event#9451
Conversation
|
Created a new revision for this PR: D12609-code |
|
Updated the revision for this PR: D12609-code |
|
@ebinnion Just updating the The Javascript hook for post-load events was my workaround for other themes as well 👍🏻. |
|
I went with this approach for now in the hopes that it might make the 6.1 release coming out this week. I like the srcset approach, but I'd want more testing before releasing it. |
|
@ebinnion Got it, makes total sense. Let me know if I can assist - my blog currently runs a slightly modified "Independent Publisher 2" Wordpress.com theme. |
gravityrail
left a comment
There was a problem hiding this comment.
Works great for me on twentysixteen. Confirmed issue and this patch fixes it.
|
Updated the revision for this PR: D12609-code |
* Lazy Images: Add jetpack-lazy-loaded-image event * Lazy Images: Provide outdent support for TwentySixteen * Lazy Images: Bail early if no image; Only update attrs if we have them
|
Ported to |
|
Can confirm, when adding The |
In #8879 it was reported that outdented images were broken in cases where the CSS class was applied after the initial page loading. In TwentySixteen, this seems to be because when the initial
1x1image loads, it wasn't meeting the condition that it be below the entry meta content.The first part of a fix here is to fire an event when we lazy load an image, which will allow themes and plugins to better integrate with Lazy Images.
I wasn't able to reproduce the multiple network requests that @PatTheMav reported in that issue. Based on his testing though, it seems possible that the issue was because we were calling
image.setAttribute()on the image in the dom. What I've tried to do in this PR is to clone the original image, update the attributes, and THEN replace the original image with the new one. I hope this fixes the issue. 🤞To test:
Here's an example of an outdented image in TwentySixteen:
Here's the same image not outdented: