-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Allow adding media attribute to picture element #48
Comments
Hey, just a short heads up. Would it be possible to integrate this or don't you plan it, right now? Thanks a lot for your feedback on this feature :) I use the Nuxt Module. Isn't it there quite easy to add it to the sources object and then add it to the picture element, quite similiar to the type property. UnLazyImage.vue:
|
Hi there! Unfortunately, nor do I have the usecase, neither the time to implement it at the moment. PR welcome! 🙌 |
Hey Johann, thanks for the feedback. I wanted to create a pull request, but when I fork and clone the project and start it locally, I get this error all the time: "Pre-transform error: Failed to resolve import "unlazy" from "src/runtime/components/UnLazyImage.vue". Does the file exist?" It seems, that it can't resolve the aliases in vite.resolve.path {}. I also tried starting the vue moduel and the nuxt module, but in both I get the same error. Do you know why this is happening? Best regards |
Right, there is currently a bug in unbuild with dev mode. That's why you need to run |
Ah okay thanks for the help. Unfortunately I can't build the unlazy package. Any idea why this is happenning? Sorry for bothering you. RollupError: Could not resolve entry module "../../../../Local%20Development/unlazy/packages/unlazy/src/bundle/index.iife.ts". |
Seems like a path resolving issue on Windows. I will have to check that further. I'm busy at the moment but will try to take a look into it in the next days. 🙋♂️ |
I am on Mac OS, but thanks so much for looking into it, when you have the time for it :) |
Can you please try again? pnpm i && pnpm build
cd packages/nuxt
pnpm dev |
Hey Johannes, thanks for looking into it. I can now build everything, but when I start the dev server, I still get the error: Pre-transform error: Failed to resolve import "unlazy" from "src/runtime/components/UnLazyImage.vue". Does the file exist? I also have completely recloned the whole project, so every dep and everything ist up to date. Do you have any more ideas? Best regards |
There seems to be some path errors, but I can't reproduce them. |
Got it to work. I had to change your calculcation of the current directory to __dirname:
|
Maybe the files couldn't be resolved because of the space in your paths. I have refactored to use |
Hey Johannes, thanks for that. I started implemented the media feature, but experienced another bug, I think: Right now we get a layout shift, when you specify only width/height. But this should we work, because I have tested with a normal img tag and there we don't get a layout shift. For the implementation of the media attribute, it should be possible to only specify width/height, because we can have different width/height values for different sources and so we don't know the aspect ratio, which wie normally can set with style aspect-ratio. Maybe you can clone my repo and then start the dev server to see it in action: The media implementation for itself is working without problems. Image.Layout.Shift.Bug.mov |
Describe the feature
Hey,
I love your plugin. It is super helpful. I now have the case where I would like to add media attributes to a picture element with your plugin, but unfortunately it is not possible right now, correct? When I add media property to the sources array, it doesn't show up in the code.
So I would like to get something like this:
Is it possible to allow this for the sourcesObject:
Thanks for your help in advance.
Best regards
Chris
Additional information
Final checks
The text was updated successfully, but these errors were encountered: