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

Prefer to pick width style from figure element instead of img if possible. #17460

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Mati365
Copy link
Member

@Mati365 Mati365 commented Nov 14, 2024

Suggested merge commit message (convention)

Fix (image): Prefer to pick width style from figure element instead of img if possible. Closes #17441


Additional information

I'm not sure if the proposed solution is optimal. In this comment I proposed another solution with additional upcast, maybe it's better?

Consider this HTML:

<figure style="clear: both;margin: 0.9em auto;min-width: 50px;text-align: center;box-sizing: border-box;display: block;max-width: 100%;width: 5.15%;"class="image image_resized">
 <img height="233" width="258" src="https://www.shutterstock.com/image-vector/sample-red-square-grunge-stamp-260nw-338250266.jpg" style="display: block;height: auto;margin: 0px auto;max-width: 100%;min-width: 100%;width: 100%;aspect-ratio: 258/233;" />
</figure>

Before

image

After

image

@Witoso
Copy link
Member

Witoso commented Nov 14, 2024

To what data does it downcast? We have height and width on image to prevent layout shift.

@Mati365
Copy link
Member Author

Mati365 commented Nov 14, 2024

@Witoso It downcasts to:

<figure class="image image_resized" style="box-sizing:border-box;clear:both;display:block;height:auto;margin:0.9em auto;max-width:100%;min-width:50px;text-align:center;width:5.15%;">
<img style="aspect-ratio:258/233;display:block;margin:0px auto;max-width:100%;min-width:100%;width:55%;" src="https://www.shutterstock.com/image-vector/sample-red-square-grunge-stamp-260nw-338250266.jpg" width="258" height="233">
</figure>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

width style from <img> overrides the style on resized <figure>
2 participants