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

Add fixed size support #117

Closed
simonihmig opened this issue Jan 24, 2021 · 0 comments
Closed

Add fixed size support #117

simonihmig opened this issue Jan 24, 2021 · 0 comments

Comments

@simonihmig
Copy link
Owner

Support fluid and fixed size images, similar to https://www.gatsbyjs.com/plugins/gatsby-image/#two-types-of-responsive-images.

Ideas:

  • switch to fixed mode by <ResponsiveImage @width={{500}} /> (sets width and height HTML attributes)
  • render the fallback src at this size (or best matching), and srcset for retina queries (1x, 1.5x, 2x)
  • add different config options for this use case, like
{
  // ...
  fixedSize: 800,
  pixelDensity: ['1x', '2x', '3x']
}
@simonihmig simonihmig changed the title Add fixes size support Add fixed size support Feb 5, 2021
simonihmig added a commit that referenced this issue 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 #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 added a commit that referenced this issue 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 #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()`
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

No branches or pull requests

1 participant