intrinsicsize-attribute icon indicating copy to clipboard operation
intrinsicsize-attribute copied to clipboard

How does 'intrinsicsize' work with 'object-fit'

Open loonybear opened this issue 5 years ago • 5 comments

This concern was bought up here. Images get distorted when using object-fit.

@dvoytenko proposed a feasible solution could be forcing object-fit:contain instead of the default object-fit:fill when 'intrinsicsize' is specified.

loonybear avatar Apr 26 '19 16:04 loonybear

Squishing images is problematic for photographs, but it's not that crazy for vector graphics. So it's not clear to me that this would be Web-compatible.

fantasai avatar May 17 '19 21:05 fantasai

@fantasai to clarify:

  1. The squishing would happen only if the actual size is different from declared size.
  2. Hopefully, it's a default at the lowest level of specificity and can be easily changed in the stylesheet.
  3. It's there to avoid stretching or otherwise deforming the image, which is arguably worse.

dvoytenko avatar May 17 '19 21:05 dvoytenko

@dvoytenko What I'm saying is that this behavior of images, that they deform when resized to a different aspect ratio, has been built into how the Web renders since the mid 1990s. While on some pages it may be an unintentional error, on others it's probably intentional. I don't think we can change this default behavior.

fantasai avatar May 17 '19 21:05 fantasai

@fantasai I think your comment might be more relevant for #4. If you agree, please repost there. The explainer proposes to add a new attribute intrinsicsize and derive the new behavior and default styling from it. It's defined this way to explicitly avoid backward compatibility issues. The #4 makes a case to change the current behavior and that debate is still ongoing there.

dvoytenko avatar May 17 '19 21:05 dvoytenko

@dvoytenko I'm not convinced changing object-fit based on the presence of intrinsicsize is a good idea. It's an unexpected interaction, and one more thing for authors to puzzle over...

fantasai avatar May 17 '19 21:05 fantasai