Skip to content

Images scale, query and <Img /> #10467

@enzoferey

Description

@enzoferey

Summary

I'm currently moving a plain HTML website to Gatsby and I wonder how I should move responsive images that use multiple scales (@1x, @2x, @3x, @4x) to use the <Img /> component.

Explanation

The images currently look like this:

<img
    src="mySrcFallback"
    srcset="mySrcSetWithTheFourDifferentScales"
    sizes="(min-width: 1200px) 50vw, 30vw"
/>

I'm aware of the different query variables such as width or maxWidth and the fluid vs fixed types, however should I just serve the @4x image and expect Gatsby to do the heavy lifting for me ? Not sure how the sizes attribute could be translated neither.

On the docs it states

Generate multiple smaller images so smartphones and tablets don’t download desktop-sized images

So I guess only serving the @4x image is fine, but what about the sizes attribute ? I guess if I set the image type to fluid it could handle it ?

Thank you very much !

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions