We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
picture
Hey! Heads up. We have extracted the core logic from next/image into a new unstable_getImgProps() function.
next/image
unstable_getImgProps()
This allows usage outside of <Image>, such as:
<Image>
background-image
image-set
context.drawImage()
new Image()
<picture>
import { unstable_getImgProps as getImgProps } from 'next/image' export default function Page() { const common = { alt: 'Hero', width: 800, height: 400 } const { props: { srcSet: dark } } = getImgProps({ ...common, src: '/dark.png' }) const { props: { srcSet: light, ...rest } } = getImgProps({ ...common, src: '/light.png' }) return (<picture> <source media="(prefers-color-scheme: dark)" srcSet={dark} /> <source media="(prefers-color-scheme: light)" srcSet={light} /> <img {...rest} /> </picture>) }
PR: vercel/next.js#51205
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hey! Heads up. We have extracted the core logic from
next/image
into a newunstable_getImgProps()
function.This allows usage outside of
<Image>
, such as:background-image
orimage-set
context.drawImage()
or simplynew Image()
<picture>
media queries to implement Art Direction or Light/Dark Mode imagesExample
PR: vercel/next.js#51205
The text was updated successfully, but these errors were encountered: