-
Notifications
You must be signed in to change notification settings - Fork 313
feat(nuxt-img): add placeholderClass prop
#1111
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
Conversation
✅ Live Preview ready!
|
|
Is there a reason |
Yes, because it will apply to the placeholder as well. There needs to be a way to style both the placeholder image AND the actual image differently. |
|
I wonder if it might be more useful to have a data attribute ( |
|
Possibly - although what if someone needs to style the placeholder? The use case that led me down this path was that I wanted to have a placeholder image load, which then gets replaced by the loaded src image. This happens with an abrupt flip from placeholder to src image, which you could transition with CSS, but not without the ability to style both the placeholder AND the src image. |
|
I suppose with but that isn't particularly elegant... |
|
Thank you for the PR! I would also go with the |
|
As long as there is a way to style both the underlying image and the placeholder image, I'm ambivalent on the implementation. So the thought is that you'd have to use Either way, that data-placeholder attribute would need to be added to the module. |
|
Also, it would be nice to have an event that is emitted when the NuxtImg changes from displaying the placeholder image to the main image, so you could do something like: <NuxtImg src='/images/user.png' placeholder="/images/default_user.png" @placeholder-replaced="doSomething" /> // if you needed to hook into when the placeholder is replacedand <NuxtImg src='/images/user.png' placeholder="/images/default_user.png" @main-image-loaded="doSomething" /> // if you needed to hook into the main image loading after placeholder was displayed |
|
I've also been trying to figure out how to hook into the HTMLImageElement's |
|
I feel it makes more sense to have a How about that? |
placeholderClass prop
This allows a user to apply a custom class to the underyling original
<img>element.Use case:
placeholderprop to have a fallback image, but wants to manipulate the loaded image src's display directly, rather than using:deepto style the<img>rendered by<NuxtImg>.