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

docs: add better examples to next/image docs. #51457

Merged
merged 1 commit into from Jun 19, 2023
Merged

docs: add better examples to next/image docs. #51457

merged 1 commit into from Jun 19, 2023

Conversation

leerob
Copy link
Member

@leerob leerob commented Jun 17, 2023

Dependent on merging images. Making it easy to copy/paste.

@stefanprobst
Copy link
Contributor

could you also add an example for fixed-size images? thanks

@leerob
Copy link
Member Author

leerob commented Jun 18, 2023

What do you mean by that, exactly?

@leerob leerob marked this pull request as ready for review June 19, 2023 04:41
@leerob
Copy link
Member Author

leerob commented Jun 19, 2023

Found myself needing this today, so really happy we'll have these copy/pastable examples 😄

CleanShot 2023-06-18 at 23 41 24@2x
<div className="columns-3 gap-4 my-8">
  <div className="relative h-40 mb-4">
    <Image
      alt="..."
      src={myImage}
      fill
      sizes="33vw"
      className="rounded-lg object-cover"
    />
  </div>
</div>

@stefanprobst
Copy link
Contributor

What do you mean by that, exactly?

adding an additional example for images which should always be displayed at a specific width and height, irrespective of viewport size, but taking device pixel ratio into account - basically how to do "layout: fixed" from the legacy image component with the new image component.

@leerob
Copy link
Member Author

leerob commented Jun 19, 2023

@stefanprobst can you explain the layout you're trying to build with that image? Trying to understand when you would never want the image to be responsive. Is it a background image of sorts?

@leerob leerob merged commit b0a704d into canary Jun 19, 2023
30 of 31 checks passed
@leerob leerob deleted the image-docs branch June 19, 2023 14:45
@leerob
Copy link
Member Author

leerob commented Jun 19, 2023

@stefanprobst going to go ahead and merge this, but we can always add more 😄

@stefanprobst
Copy link
Contributor

@leerob

can you explain the layout you're trying to build with that image? Trying to understand when you would never want the image to be responsive. Is it a background image of sorts?

let's say we are building a /team page, which should display images of team members at 300x300 pixels, but the original photos are huge, so we want to use the next image component to reduce the size of these photos, because they will only ever be displayed at 300x300 or at 600x600 on high-dpi screens.

@leerob
Copy link
Member Author

leerob commented Jun 19, 2023

You would probably still want those images to be responsive when going down to mobile though, right?

I believe you'd use sizes here: https://nextjs.org/docs/app/api-reference/components/image#sizes

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants