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

Support fixed and responsive layouts #130

Merged
merged 1 commit into from
Feb 5, 2021
Merged

Support fixed and responsive layouts #130

merged 1 commit into from
Feb 5, 2021

Conversation

simonihmig
Copy link
Owner

@simonihmig simonihmig commented Feb 5, 2021

This accumulates a few (breaking) changes:

  • will add the CSS for responsive (fluid) image layout (the default)
  • when passing @width and/or @height arguments, it will opt into fixed layout (closes Add fixed size support #117)
  • in fixed layout, it will pick the (fallback) src attribute based on the fixed width, pick srcset sources for that given width and pixel densities of 1x and 2x, and render width and height attributes with the appropriate fixed values (if one is missing, it will be computed based on the image's aspect ratio)
  • in responsive layout, width and height attributes are rendered even though the actual size is responsive, to let the browser know the correct vertical size (even before the image has been loaded), to reduce Cumulative Layout Shift (Closes Set width/height attributes on <img> #88)
  • some (breaking) related changes in the service's API, removing getImageBySize(), renaming getImageDataBySize() to getImageMetaBySize() and introducing getImageMetaByWidth()

@simonihmig
Copy link
Owner Author

@andreasschacht @lolmaus some bigger changes of the component API / feature set 👆 Feel free to chime in if you have thoughts!

This accumulates a few (breaking) changes:
* will add the CSS for responsive (fluid) image layout (the default)
* when passing `@width` and/or `@height` arguments, it will opt into fixed layout (closes #117)
* in fixed layout, it will pick the (fallback) `src` attribute based on the fixed width, pick `srcset` sources for that given width and pixel densities of `1x` and `2x`, and `width` and `height` with the appropriate fixed values (if one is missing, it will be computed based on the image's aspect ratio)
* in responsive layout, `width` and `height` attributes are rendered even though the *actual* size is responsive, to let the browser know the correct vertical size (even before the image has been loaded), to reduce [Cumulative Layout Shift](https://web.dev/cls/) (Closes #88)
* some (breaking) related changes in the service's API, removing `getImageBySize()`, renaming `getImageDataBySize()` to `getImageMetaBySize()` and introducing `getImageMetaByWidth()`
@simonihmig simonihmig merged commit bbfa310 into dev-v2 Feb 5, 2021
@simonihmig simonihmig deleted the image-layout branch February 5, 2021 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant