You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
This PR addresses and fixesIssue #43869, where SVG images without a width attribute were not displayed correctly in the FocalPointPicker component. The issue arose because such SVG images defaulted to width: 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 the FocalPointPicker component, the image would not display properly due to its width defaulting to 0. 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 the FocalPointPicker component.
How?
The implementation involves:
Updating the styles applied to the FocalPointPicker component.
Adding CSS rules to enforce width: 100% and height: auto for SVG images, ensuring they are displayed properly while maintaining their aspect ratio.
Testing Instructions
To test this PR:
Open the block editor in WordPress.
Add a block that uses the FocalPointPicker component (e.g., a Cover block).
Upload an SVG image that does not include a width attribute (e.g., use the SVG file provided in Issue #43869).
Verify that:
The SVG image is displayed correctly within the FocalPointPicker.
Adjusting the focal point works as expected.
No regressions occur for other image types.
Screenshots
Before
After
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.
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.
FixesWordPress#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 props-bot label.
If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
@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.
FocalPointPicker: Fix SVG display when it doesn't provide a width attribute.
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.