Skip to content
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: Remove broken support for HTML4 img percentage width/height #17300

Merged
merged 1 commit into from
Oct 7, 2020

Conversation

anomiex
Copy link
Contributor

@anomiex anomiex commented Sep 29, 2020

Fixes #9833

Changes proposed in this Pull Request:

  • Removes the attempted support for HTML4 percentage width/height in the Photon code. It has never conformed to HTML4 semantics, and since 2016 it hasn't even correctly implemented the "percentage of the image's native width/height" semantics.

Jetpack product discussion

See #9833

Does this pull request change what data or activity we track or use?

No

Testing instructions:

  • Enable Photon, if necessary.
  • Using the code editor, attempt to add an <img> tag with percentage values for width and/or height.
  • The resulting HTML should ignore the supplied percentage width/height, acting the same as if you had omitted the attribute entirely.

Proposed changelog entry for your changes:

  • Perhaps something like "Jetpack's image accelerator (Photon) will now ignore attempts to specify percentages for width or height in an <img> tag. This hasn't worked correctly since 2016, and even before that did not follow HTML4 semantics."?

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
@anomiex anomiex added [Feature] Photon aka "Image CDN". Feature developed in the Image CDN package and shipped in multiple plugins [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. labels Sep 29, 2020
@anomiex anomiex self-assigned this Sep 29, 2020
@jetpackbot
Copy link
Collaborator

Scheduled Jetpack release: October 6, 2020.
Scheduled code freeze: September 29, 2020

E2E results is available here (for debugging purposes): https://jetpack-e2e-dashboard.herokuapp.com/pr-17300

Thank you for the great PR description!

When this PR is ready for review, please apply the [Status] Needs Review label. If you are an a11n, please have someone from your team review the code if possible. The Jetpack team will also review this PR and merge it to be included in the next Jetpack release.

Generated by 🚫 dangerJS against 450392b

@jeherve jeherve added this to the 9.1 milestone Sep 29, 2020
Copy link
Contributor

@kraftbj kraftbj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tackling this.

@kraftbj kraftbj added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. labels Oct 6, 2020
@anomiex anomiex merged commit a0ebdc1 into master Oct 7, 2020
@anomiex anomiex deleted the remove/9833-photon-percent-width branch October 7, 2020 15:38
@matticbot matticbot added [Status] Needs Changelog and removed [Status] Ready to Merge Go ahead, you can push that green button! labels Oct 7, 2020
jeherve added a commit that referenced this pull request Oct 27, 2020
cbuchart added a commit to stt-systems/stt-systems.com that referenced this pull request Nov 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Photon aka "Image CDN". Feature developed in the Image CDN package and shipped in multiple plugins [Pri] Normal [Type] Janitorial
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Photon: images with width="100%" converted to width="100"
5 participants