style: Preserve aspect ratio for images in text-content #13305
style: Preserve aspect ratio for images in text-content #13305exrok wants to merge 1 commit intorust-lang:mainfrom
Conversation
Style images on create pages with `height: auto;`, to allow the height to be automatically scaled based on width, even an explicit height was used on the img tags. Explicit width and height attributes are helpful reduce relayout as the image loads. Github has started adding the automatically, without this fix the width would be clamped to page, but height would be value that was specified causing image to be distored.
|
I poked around the GitHub behaviour here. It looks like what happens there is:
I wonder if we should do that instead to better match GitHub, rather than unconditionally setting @rust-lang/crates-io Does anyone else have thoughts here? |
|
I think matching GitHub's behaviour seems reasonable and safe. After a little testing the difference seems to be that if some one wanted to intentionally distort the image, Like say the image is natively 500x500, but they wrote I'll need to take a deeper look, but expect if we go with Github's I exact approach it should be done in the markdown -> HTML, rather then just the CSS. Edit: I did briefly look into doing the inline style version in |
Style images on create pages with
height: auto;, to allow the height to be automatically scaled based on width, even if an explicit height was used on the img tags.Note: You might consider the
imgis wrong for adding height and width but explicit width and height attributes are helpful reduce re-layout as the image loads. Github has started adding the automatically, without this fix the width would be clamped to page, but height would be value that was specified causing image to be distorted.Where I originally noticed the issue.