-
Notifications
You must be signed in to change notification settings - Fork 800
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: Do not remove width and height attributes when known #8196
Conversation
Awesome to see you working on this! I just wanted to add a link to #529 (comment) , since we've discussed issues with |
Looking at the fieldguide I found a bit of information about how devicepx is supposed to work:
Based on that, I would not expect devicepx to resize when In testing, that seemed to be the case. Here are some examples from my site with this branch checked out: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have confirmed that this fixes my issues with Photon + Lazy Images, and that width and height appear to be correct for my photon images.
I added a couple of clarification comments, but have not changed functionality. Thank you for the review @gravityrail! |
$new_tag = preg_replace( '#(?<=\s)(width|height)=["|\']?[\d%]+["|\']?\s?#i', '', $new_tag ); | ||
// If we are not transforming the image with resize, fit, or letterbox (lb), then we should remove | ||
// the width and height arguments from the image to prevent distortion. Even if $args['w'] and $args['h'] | ||
// are present, Photon does not crop to those dimensions. Instead, it appears to favor height. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If photon favours height, could we keep the height attribute and leave out the width attribute for this case? This might go some way towards alleviating the issues with pages reflowing over and over while infinite-scrolling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. I'll make that change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After looking into this some more, I don't think this will work how we want.
In testing, it seems to work when the image is treated as a block level element. For example, if a paragraph immediately comes after the image, then the proper height will be reserved. But, if the image or paragraph is floated, then reflowing will still occur.
Dismissing to address feedback
Feedback was addressed. This is ready for review again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
* Changelog 5.6: create base for changelog. * Update changelog with 5.5.1 info. * Changelog: add #7930 and #8238 * Changelog: add #8076 * Changelog: add #8100 * Changelog: add #8117 * Changelog: add #8141 * Changelog: add #8143 * Changelog: add #8147 * Changelog: add #8149 * Changelog: add #8153 * Changelog: add #8173 * Changelog: add #8184 * Changelog: add #8196 * Changelog: add #8199 * Changelog: add #8093 * Changelog: add #8171 * Changelog: add #8182 * Changelog: add #8202, #8222 * Changelog: add #8228 * Changelog: add #8240 * Changelog: add #8251 * remove AL card change
Fixes #8191
Until now, when filtering content, Photon has removed width and height attributes from img tags. This makes sense in certain cases since we optimize and resize the image on WordPress.com. If we resize the image, but left the width and height attributes the same, it could cause distortion.
But, it also causes issues, which are described in #8191.
To address the issue, I am proposing that instead of always removing the width and height attributes, that we update the width and height instead.
To test: