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
How to reference different sizes in a template #68
Comments
@bparticle – do
And then use in your HTML
And your srcSet will be set up. |
@Melzmr Thanks for your reply! Your answer makes perfect sense, and it is one of the options out of many I tried, but somehow nothing works. I'm still scratching my head over this but can't let it go. I'm using Vue.js at the moment and this is the code I'm currently testing:
The only positive response I get is the raw responsiveImage reference in the first <p> tag. It's outputting the base64 code that is supposed to contain the image (data:image/jpeg;base64,bW9kdWxlLmV4cG9ydH......). If I put this in the image tag however I get a broken image link. The other tests aren't outputting anything at all (responsiveImage.src and .srcSet). |
@bparticle looks like you have another loader hijacking your image (probably |
@herrstucki That will be the case probably. I think the way vue-cli is implementing its webpack configuration is awkward to say the least. I tried to set it up like this:
But the trouble with that setup is not immediately relevant to this repository I suppose! |
I found the issue (and it cost me many hours so I hope this may help anyone in the same situation). My images were not displayed due to the preceding slash that I put in the responsive-loader configuration (see previous code example). Also I changed the way I implement the loader in the vue-cli setup. This setup has fixed my problem:
So name: 'assets/img/[hash]-[width].[ext]' instead of name: '/assets/img/[hash]-[width].[ext]'. |
For other templates using picture
source(media='(min-width: 1024px)', srcset=`${src}?size=1280`)
source(media='(min-width: 768px)', srcset=`${src}?size=1024`)
source(media='(min-width: 640px)', srcset=`${src}?size=768`)
source(media='(min-width: 481px)', srcset=`${src}?size=640`)
img(src=`${src}?size=481`, loading='lazy', alt=alt) Multiple |
Responsive-loader is generating all my images beautifully with the correct names and sizes, but I can't figure out how to reference other sizes than the default (smallest one) in my template!
And this is how I'm referencing the images in my template html
This gives me the 600px wide image and I would like to get different images based on screen size. Any pointers?
The text was updated successfully, but these errors were encountered: