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

Revert changes made in #19 and #23 #41

Closed
wants to merge 1 commit into from
Closed

Conversation

dkotter
Copy link
Collaborator

@dkotter dkotter commented Mar 1, 2022

Description of the Change

In PR #19, we fixed a bug around calculating the height and width of an SVG to properly use the height and width attributes and then fallback to the viewbox attribute. This was definitely a bug that was good to fix but the issue here is for any previously uploaded SVGs that had different dimensions in the height and width attributes as compared to theviewbox attribute, this can cause wrong image dimensions to now be used.

For instance, if an SVG had a viewbox of 0 0 32 32 and a width of 200 and height of 200, even though we look at height and width first, because of the bug, those values were never used and instead, 32x32 would be used as the SVG dimensions (and stored as image meta). With the bug fix introduced in #19, we now properly use the height and width attributes but in this example, we still have 32x32 stored, so we end up with two different image dimensions. This can cause the SVG to be either too big or too small and we also output two separate height and width attributes on the resulting <img> tag. This PR reverts that particular change. This does re-introduce the originally reported bug, which we'll need to still solve.

In PR #23, we fixed a bug around overriding the height and width values of an image to be false, when those values are expected to be of the type integer. This was causing an issue with certain aspects of Full Site Editing (the logo block in particular) and could potentially cause issues elsewhere. This is again a legitimate bug that should be fixed but this introduced some issues.

In particular, if directly using wp_get_attachment_image, the size requested will now be used for the image tag, instead of the actual size of the SVG. As an example, an SVG with dimensions of 30x30 but a requested image size of medium (default to 300x300), 300x300 will be used on the resulting <img> tag, making that SVG larger than expected. This PR reverts that change and thus brings back the original issue but resolves backwards compatibility.

Checklist:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests passed.

Changelog Entry

Fixed - Reverted fix to properly use the SVG height and width attributes, not just viewbox. Reverted fix around using the proper image dimensions instead of false

@dkotter dkotter self-assigned this Mar 1, 2022
@jeffpaul jeffpaul added this to the 2.0.0 milestone Mar 1, 2022
@jeffpaul jeffpaul requested review from darylldoyle, a team and iamdharmesh and removed request for a team March 10, 2022 20:24
Copy link
Member

@iamdharmesh iamdharmesh left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks @dkotter.

@jeffpaul
Copy link
Member

I'd ideally like to have another PR ready to fix the root issue for the revert so that these could land in tandem and get into another release.

@dkotter
Copy link
Collaborator Author

dkotter commented Mar 11, 2022

Yep, I agree. I've opened #43 and #44 that I think solve both of these, both the original issue and the newly introduced issues. Going to close this out

@dkotter dkotter closed this Mar 11, 2022
@vikrampm1 vikrampm1 removed this from the 2.0.0 milestone May 25, 2022
@jeffpaul jeffpaul deleted the revert-19-23 branch November 2, 2023 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants