-
Notifications
You must be signed in to change notification settings - Fork 273
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
feat!: screen based responsive #182
Conversation
Co-Authored-By: Sebastien Chopin <[email protected]>
I am looking for a way to support the generation of This mean the image will take the device size on small device (browser will get the closest image ratio defined from screens) and get the 720px for bigger screens. |
The PR currently breaks What if we support using a string as value, like this: <nuxt-img sizes="{ md: '100vw', lg: 720 }" /> This would have the effect to generating: <img src="/_ipx/images/damavand.jpg?w=800" sizes="(max-width: 768px) 100vw, 800px" srcset="/_ipx/images/damavand.jpg?w=640 640w, /_ipx/images/damavand.jpg?w=768 768w, /_ipx/images/damavand.jpg?w=800 800w"> When the value is We would need to generate the image size for all breakpoints smaller and equal to the one specifying Another proposal: <nuxt-img fluid sizes="{ lg: 720 }" />
If |
@atinux Both good ideas. Just consider for fluid support we need:
I would suggest an API like below: <nuxt-img :fluid="{ lg: 60, md: 80, sm: 100 }" /> ( Alternative: <nuxt-img :sizes="{ lg: 60, md: 80, sm: 100 }" fluid /> Generates: <img src="img.jpg?w=614"
sizes="(max-width: 640px) 100vw, (max-width: 768px) 80vw, 60vw"
srcset="img.jpg?w=640 640w, img.jpg?w=614 614w"
> Remarks:
Note: |
Co-authored-by: Sebastien Chopin <[email protected]>
Currently, responsive prop is generating breakpoints by assuming image layout is fuild (filling screen width).
sizes
option replaced byscreens
responsive
attr fromnuxt-img
sizes
attr fornuxt-picture
andnuxt-img
accept a new objectsrcSet
tosrcset
everywheresrcset
andsizes
improvedUsage with
<nuxt-img>
:Generates:
Default value for screens: (inspired by tailwind breakpoints)
Try locally
yarn && yarn dev