Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

next/image media query display filtering for priority images #45341

Closed
kirkstrobeck opened this issue Jan 27, 2023 · 2 comments
Closed

next/image media query display filtering for priority images #45341

kirkstrobeck opened this issue Jan 27, 2023 · 2 comments
Labels
Image (next/image) Related to Next.js Image Optimization.

Comments

@kirkstrobeck
Copy link

kirkstrobeck commented Jan 27, 2023

Describe the feature you'd like to request

  1. If I have a desktop image and a mobile image, next/image will only load the mobile or desktop image accordingly
  2. If I add priority, then both the mobile and desktop images will load in all cases
  3. Omitting priority impacts my LCP, adding priority means the user has to download an additional large image
  4. I would like to be able to specify that an image should only be visible at a certain media-query

Describe the solution you'd like

Example

<>
  {/* I only load on mobile */}
  <Image
    alt="Picture of the author"
    media="(max-width: 699px)"
    height={500}
    priority
    src="me-mobile.jpg"
    width={500}
  />

  {/* I only load on desktop */}
  <Image
    alt="Picture of the author"
    media="(min-width: 700px)"
    height={500}
    priority
    src="me-desktop.jpg"
    width={500}
  />
</>

Describe alternatives you've considered

Manually creating an img tag with sizes or source and specifying media-queries there

@kirkstrobeck kirkstrobeck changed the title next/image priority for viewport next/image media query display filtering for priority images Jan 27, 2023
@balazsorban44 balazsorban44 added the Image (next/image) Related to Next.js Image Optimization. label Jan 27, 2023
@thexpand
Copy link

thexpand commented Feb 8, 2023

This is related to #21379 and #19880
To be honest, this has been around for 2 years and there is still no resolution from Vercel. I lost any hope.

@lachlanjc
Copy link
Contributor

Indeed, we've needed this for awhile; I run into it nearly weekly. Vercel's blog uses different versions of images both in dark & light modes & desktop & mobile, but they load each of the variants regardless of which is rendered, unfortunately.

@vercel vercel locked and limited conversation to collaborators Apr 17, 2024
@balazsorban44 balazsorban44 converted this issue into discussion #64615 Apr 17, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Image (next/image) Related to Next.js Image Optimization.
Projects
None yet
Development

No branches or pull requests

4 participants