question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to get srcset to work as expected

See original GitHub issue

Using version 1.2.2 with Vue 2.5.15

I’m not able to get srcset to work as expected. The following output without your plugin works as expected in Chrome:

<img
  srcset="http://via.placeholder.com/180x150 180w,http://via.placeholder.com/250x150 250w,http://via.placeholder.com/350x150 350w,http://via.placeholder.com/500x150 500w"
  sizes="(min-width: 1024px) 48.828125vw,(min-width: 768px) 45.57291666666667vw,100vw">

When replacing srcset with data-srcset and adding v-lazy="'http://via.placeholder.com/180x150'" the 180x150 image is always shown. What do I oversee? Why is data-srcset not just converted to srcset when the image needs to be loaded and let the browser do the calculation (I know there would have to be a polyfill for older browsers)?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:8
  • Comments:30 (8 by maintainers)

github_iconTop GitHub Comments

7reactions
Jones-Scommented, Feb 8, 2019

This has been around for quite a while and is definitely of a reason not to use this plugin anymore… Is there anyone who got this problem solved?

5reactions
Ra1nkocommented, Sep 4, 2019

You can use adapter to make data-srcset work i guess It seems that lazyload don’t change data-srcset to srcset by default

`

Vue.use(VueLazyload, {
  ...
  adapter: {
    loaded ({el}) {
        const srcSet = el.attributes['data-srcset'];
        if (srcSet) {
            el.setAttribute('srcSet', srcSet.value);
        }
    },
  }
});

`

Read more comments on GitHub >

github_iconTop Results From Across the Web

responsive images srcset not working - Stack Overflow
Im using chrome 40 and all I get is the largest image, resizing my browser, clearing the cache does nothing. I read somewhere...
Read more >
srcset not working? Getting Wrong Images? Let's Find Out Why!
Sometimes, when srcset is not working and the browser is using the wrong image, it can be frustrating. This guide will help you...
Read more >
The Media or Image Source element - HTML - MDN Web Docs
It is a void element, meaning that it has no content and does not have a closing tag. It is commonly used to...
Read more >
Picture perfect images with the modern <img> element
Use srcset + efficient modern image formats; Avoid wasting pixels (compress, don't serve overly high DPR images); Lazy-load offscreen images ( ...
Read more >
Responsive Images: If you're just changing resolutions, use ...
If you want, you can get all kinds of specific about it. You can use sizes to match your CSS layout exactly and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found