image icon indicating copy to clipboard operation
image copied to clipboard

feat: `mobileFirst` sizes strategy

Open nagman opened this issue 3 years ago • 2 comments

Hi,

I've added a feature that allows developper to opt between desktop-first and mobile-first strategies.

The default behavior is desktop-first (because it uses max-width media queries in the sizes attribute), but the recommended approach for CSS is mobile-first.

So in order to keep consistency between template and css, we can now opt for mobile-first strategy, and it will replace the media-queries with a min-width syntax, and sort the screens in descending order (while keeping the lowest screen as the default one).

Looking forward to use this feature in my current project :)

I've also updated the docs part on sizes as it was not detailed enough for developers who really care about image optimization.

nagman avatar Feb 03 '22 10:02 nagman

Nice PR! I'm thinking, the term strategy could be used for something more "image-related" in the future. Hence I'd suggest an option name more descriptive for this feature like:

  • breakpointStrategy
  • responsiveStrategy
  • mqStrategy
  • mobileFirst? (then it would be a boolean, set to false by default) - Seems to be the best option IMO as I don't think there would be a value other than 'mobile-first' or 'desktop-first'

mickaelchanrion avatar Feb 14 '22 18:02 mickaelchanrion

Here, I've renamed it to mobileFirst and it's a boolean, now

nagman avatar Feb 15 '22 13:02 nagman

Also interested in this feature. Hope it will be merged.

frodrigo avatar Nov 15 '22 14:11 frodrigo

Any chance this gets picked back up? We hit it a scenario today wanting to use preload but only for desktop images. I believe this would solve it.

RyanMulready avatar Apr 18 '23 00:04 RyanMulready