Ensure SVG Images Without a Width Attribute Are Displayed Correctly in FocalPointPicker #70061
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
FocalPointPicker
component. 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: auto
to maintain the aspect ratio of the SVG.Why?
Previously, when an SVG image lacking a
width
attribute was uploaded and used with theFocalPointPicker
component, 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 theFocalPointPicker
component.How?
The implementation involves:
FocalPointPicker
component.width: 100%
andheight: auto
for SVG images, ensuring they are displayed properly while maintaining their aspect ratio.Testing Instructions
To test this PR:
FocalPointPicker
component (e.g., a Cover block).width
attribute (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
FocalPointPicker
component are unaffected.Closes #43869.