-
Notifications
You must be signed in to change notification settings - Fork 287
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
Make width
, height
and alt
required props
#1612
Comments
The console warning is a particularly useful addition. Waiting for the draft |
@danielroe what do you think about that? :) |
There are cases where leaving the alt attribute empty makes sense. For example, decorative images that don't add meaningful context can be hidden from screen readers by using alt="". This helps keep the experience clear and focused for users relying on assistive technologies. |
Thanks for the comment @madc What about then checking if an alt is empty but provided in this case? So if a user will not provide prop it will display warning but but if they pass an empty string it will not display a warning? :) |
Width and height can be auto generated. Let's assume I think this And following this logic I don't see the need for sizes, as it's possible to do extend width syntax: With pixel-sizes it's even easier: And empty width: |
Sounds reasonable. I wonder if this approach will not indicate to users that they could be using sizes for optimized images (in Lighthouse for example) and the users will try to use while it will no longer be needed. And for the alt we could check if it was not provided (including the comment above) and if user will not provide anything, show a warning in the console. WDYT? |
@razbakov The width/height size doesn't matter (as the actual size of the image can be set in CSS), it's only the aspect ratio that is significant to the browser. Your example assumes we know it's square. If that's the case, you can just set More generally, it would be a very nice enhancement to support detecting sizes of images at build time, perhaps only with I would also be up for (as an easy first step) showing a warning in development when height/width are omitted. (Later we can move this to the |
Hey there!
In Nuxt Cloudinary module we have these props as required to promote good practices for images.
If you omit these props, popular tools such as Lighthouse can report this as an issue.
Do you think that we could add these props to Nuxt Image as well as required? Or maybe add a warning in the console that you should add them to have better score and overall :)
I can create a draft PR with this change if you would like to test how it works :)
The text was updated successfully, but these errors were encountered: