Image rendering fixes#29
Open
viinikv wants to merge 1 commit into
Open
Conversation
Fix image size when width and height attributes are set. Fix gap in card images with fonts other than Open Sans.
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.
1:
Adding width and height attributes to an image changes it's size. They are recommended to prevent layout shifts: MDN: preventing jank when loading images. However now the image gets rendered using height from this attribute, and
width: 100%. This results in a larger image that is also cropped from the sides. Addingheight: autofixes this. I don't know if this is important enough forclassless-tiny.cssbut added it anyway.Could we now remove
object-fit: cover? As far as I understood, it only does anything when width and height specify a different aspect ratio than the image natively has, andheight: autouses the native ratio. I guess it could still be useful if somebody sets min-height or max-height elsewhere (or overrides height).2:
Images inside cards have a gap at the top with fonts other than Open Sans. Inline rendering means that the 3px gap is font-dependent. Fixed by
display: blockand removing the negative margin.Also, the documentation says:
but that's not true if the image is narrower than the card. Maybe there should be a
width: calc(100% + 1.2rem)to set this?