Repository navigation
Ensure SVG Images Without a Width Attribute Are Displayed Correctly in FocalPointPicker - #70061
Merged
Mamaduka merged 3 commits intoMay 27, 2025
Conversation
Previously, SVG images without a width attribute were not displayed correctly in the FocalPointPicker component as they defaulted to width: 0. This fix ensures SVG images are properly displayed by using width: 100% and maintaining aspect ratio through height: auto in the styled components. Fixes WordPress#43869
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Member
|
@vk17-starlord, do you mind adding a changelog entry for this fix? It could be something along these lines. You can see style examples in changelog.md file. |
Contributor
Author
|
@Mamaduka I have added changelog entry for this fix |
chriszarate
pushed a commit
to chriszarate/gutenberg
that referenced
this pull request
Jul 1, 2025
…n FocalPointPicker (WordPress#70061) Co-authored-by: vk17-starlord <vineet2003@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: artemiomorales <artemiosans@git.wordpress.org> Co-authored-by: lichtmetzger <dscqbus@git.wordpress.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
This PR addresses and fixes Issue #43869, where SVG images without a width attribute were not displayed correctly in the
FocalPointPickercomponent. The issue arose because such SVG images defaulted towidth: 0, rendering them invisible in the UI.The fix ensures that SVG images are displayed properly by enforcing the following styles via CSS:
width: 100%to make the SVG scale appropriately.height: autoto maintain the aspect ratio of the SVG.Why?
Previously, when an SVG image lacking a
widthattribute was uploaded and used with theFocalPointPickercomponent, the image would not display properly due to its width defaulting to0. This created a poor user experience, as users could not adjust the focal point for SVGs. The fix ensures consistency across different types of images used with theFocalPointPickercomponent.How?
The implementation involves:
FocalPointPickercomponent.width: 100%andheight: autofor SVG images, ensuring they are displayed properly while maintaining their aspect ratio.Testing Instructions
To test this PR:
FocalPointPickercomponent (e.g., a Cover block).widthattribute (e.g., use the SVG file provided in Issue #43869).FocalPointPicker.Screenshots
Additional Notes
This fix ensures compatibility and a better user experience for users working with SVG images in the block editor. It has been tested to verify that other image formats and features of the
FocalPointPickercomponent are unaffected.Closes #43869.