-
Notifications
You must be signed in to change notification settings - Fork 799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Photon: Filter Responsive Images srcset array #2885
Conversation
I like the direction of this (relying on core's method overall for now). The downside is it Photonizes™ the resized image, not the full-size image with the Photon query args. E.g. typically an image at https://kraft.im/uploads/IMG_20151018_2018382-520x700.jpg is converted to https://i2.wp.com/kraft.im/uploads/IMG_20151018_2018382.jpg?resize=520%2C700 and all other sizes of that image are dynamically resized from that original. The PR just adds the i{0-2}.wp.com, but ignore the WP resized-to-full-size conversion. I'd need to play with it more, but I think we need to pull out the dimensions for the query string and remove it from the file name a la https://github.com/Automattic/jetpack/blob/master/class.photon.php#L268-L299 My initial thought is we need to abstract out the content filtering function and reference new functions (e.g. |
f3ee86f
to
1ffcec2
Compare
This looks good to me, works as expected! |
Based on some discussion in Core Slack and at Trac#34430 (34430.3.diff), should we expect that we won't need to scrape the width and height and instead receive the dimensions via the filter (as |
@aduth Agreed, assuming .3 or similar functionality is merged. Worst case, this branch functionally works as trunk stands right now and would work whether or not .3 is merged, so if we're ready for 3.8 and this is still pending, we can ship this and be good for now. Better case, we can hold off until Core settles down and pick the most efficient/performant solution. |
Both the patch and the plan WFM -- Holding off on merging this until right before beta-2 (slated for wednesday EOD or early Thursday) |
Core has been updated to include a sizes_array available via the filter. The downside is it only includes width. The sources array passed through the filter outputs something akin to
The sizes_array: The image meta looks like |
I'm wondering if it still just makes sense to do how we're doing it. Relevant core change: https://core.trac.wordpress.org/changeset/35412 tl;dr: The PR still works with the changes. I'm not sure if the new changes to Core does anything to help us do it better. |
@zinigor made a point in Slack that Photon can just take the width and figure out the height from there. Removing the call to determine the height would remove a |
0c2788d
to
d6dda07
Compare
Looks awesome! Tested again on latest nightly, works as expected. |
Photon: Filter Responsive Images srcset array
Related (Resolves?): #2804
This pull request seeks to update Photon to adjust image URLs included in the
srcset
attribute introduced as part of the WordPress 4.4 "Responsive Images" feature.This is a relatively naive approach. It simply filters the
wp_get_attachment_image_srcset_array
array applied by the corewp_get_attachment_image_srcset_array
function. It may be preferable to hook in to and override thesizes
returned bywp_get_attachment_metadata
, as this is the mechanism used by thesrcset
behavior to determine viable responsive image candidates.