-
Notifications
You must be signed in to change notification settings - Fork 809
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: images with width="100%" converted to width="100" #9833
Comments
Another potential similar issue in here: https://wordpress.org/support/topic/cannot-get-big-image-size/ |
@htdat can you have a look at this for me? When checking the page source, here's the output for the original file: I'm sure I'm missing something. Can you help me out with that? Thanks a lot! |
(I'm the user from the forum thread) Are there any workaround for this other than disabling photon? |
I just disabled photon for now. I ran into another issue with images not loading that also were solved by disabling photon. Disabling it on this site was ok since I don't have much media there. |
@olind We have not made progress on this yet. Is there any reason you need to use percentages instead of pixel values? Percentages are not valid HTML5 anymore, so this may not be something we'll support soon. |
@jeherve Thanks. I don't think I have set any pixel or percentage widths on my side (Gutenberg). The HTML on my side in Gutenberg looks like this:
That gets transformed to:
I'm not sure it's a photon issue though... Or related to the issue above... Sorry... I can send you the URL to the page in PM but it's not official yet so I'll rather not post here. |
Yes, that's a known issue with Gutenberg at the moment. The |
We're seeing the same issue with an imported site, where a post with image tag like <img class="aligncenter" width="100%" src="https://xxxxx.jpg"> is translated to <img class="aligncenter" src="https://i0.wp.com/xxxxx.com/wp-content/uploads/2017/12/xxxxx.jpg?zoom=2&w=100%25&ssl=1" width="100" height="150"> p1539159844000100-slack-calypso-importers |
For imported posts, my gut tells me it is this line not accounting for % in the width. https://github.com/Automattic/jetpack/blob/6.6.1/class.photon.php#L295 We'd need to likely not specific width/height args when a % is present, then likewise make sure we don't modify the width/height attributes in the img tag. For a change like this, I would require unit testing given the testing coverage already in Photon and how any future changes could easily introduce a regression unintentionally. |
Having the same issue. Created a custom post type and in the import template utilized width=100% for the hero image. When enabling Jetpack Site Accelerator those are the only images that have issues as the image displayed is 100px width. Is there a workaround for this issue? |
As a workaround, I would recommend against using percentages for the |
Here's my workaround. PHP:
Javascript:
|
This issue has been marked as stale. This happened because:
No further action is needed. But it's worth checking if this ticket has clear reproduction steps and it is still reproducible. Feel free to close this issue if you think it's not valid anymore — if you do, please add a brief explanation. |
2698815-zen |
Noting we ran into this today on a Team 51 project. We implemented the workaround suggested in #9833 (comment) |
After looking into this, we've determined that this has probably been broken since 2016. Given that it has been broken so long with little outcry, and that people entering If anyone really wants us to consider alternatives such as restoring the former "percentage of the image's native size" behavior, we'd be happy to hear about your use case and why it couldn't be worked around by specifying pixel dimensions. |
Added the wontfix label, but removed it. :) We won't restore the functionality (since I concur that I don't think it ever really did what was expected), but still need to gracefully handle when the value is present. |
Attempts to support percentages go back to at least 2012, but have never actually implemented HTML4's semantics where a percentage width/height is relative to the containing element or viewport. Instead they were using a feature of the Photon scaler that interpreted percentages relative to the image's native dimensions. And even that was broken back in 2016, when a refactor caused the Photon scaler to interpret percentages as integer pixel widths. Since there hasn't been much outcry over the breakage since 2016, and it has never worked with the HTML4 semantics people were probably expecting, and the block editor doesn't even support entering percentages for image width/height, and supplying pixel dimensions for both width and height will result in better-performing HTML output, we've decided to just drop the attempt at supporting percentage width/height. If they are supplied, they'll be ignored. This patch also cleans up a few comments elsewhere in the method, and rearranges one complicated nested if structure to be more straightforward. Fixes #9833
…17300) Attempts to support percentages go back to at least 2012, but have never actually implemented HTML4's semantics where a percentage width/height is relative to the containing element or viewport. Instead they were using a feature of the Photon scaler that interpreted percentages relative to the image's native dimensions. And even that was broken back in 2016, when a refactor caused the Photon scaler to interpret percentages as integer pixel widths. Since there hasn't been much outcry over the breakage since 2016, and it has never worked with the HTML4 semantics people were probably expecting, and the block editor doesn't even support entering percentages for image width/height, and supplying pixel dimensions for both width and height will result in better-performing HTML output, we've decided to just drop the attempt at supporting percentage width/height. If they are supplied, they'll be ignored. This patch also cleans up a few comments elsewhere in the method, and rearranges one complicated nested if structure to be more straightforward. Fixes #9833
Steps to reproduce the issue
What I expected
My image looks good.
What happened instead
The output HTML looks like this:
From 1193726-zen
The text was updated successfully, but these errors were encountered: