Skip to content

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

@kirkstrobeck

Description

@kirkstrobeck

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Image (next/image)Related to Next.js Image Optimization.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions