Skip to content
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

background image callback_error demo is not correct #573

Closed
Soul244 opened this issue May 30, 2022 · 1 comment
Closed

background image callback_error demo is not correct #573

Soul244 opened this issue May 30, 2022 · 1 comment

Comments

@Soul244
Copy link

Soul244 commented May 30, 2022

Is your feature request related to a problem? Please describe.
background images demo is not correct for callback_error function.

https://github.com/verlok/vanilla-lazyload/blob/master/demos/background_images.html

If you are using an image as background-image, you have to set your fallback image to style.backgroundImage property of that element. So, we should change this example.

Describe the solution you'd like

callback_error: (element) => {
       const name = element.tagName.toLowerCase();
      if (name === 'img') {
        element.setAttribute('src',  "https://via.placeholder.com/220x280/?text=Error+Placeholder");
      } else {
        element.style.backgroundImage = "url('https://via.placeholder.com/220x280/?text=Error+Placeholder')";
      }
  },

By this example, we are setting src of element if that element is an image, otherwise we are setting backgroundImage property.

Describe alternatives you've considered
or just change it with this:

element.style.backgroundImage =  "url('https://via.placeholder.com/220x280/?text=Error+Placeholder')";
@verlok
Copy link
Owner

verlok commented Jul 20, 2022

Hey @Soul244,
thank you for pointing this out, I changed the 3 demos with background images and released a new minor.
I also tagged you and this issue in the release notes.

If you’re happy with my support, the documentation and the effort I’ve been putting on this project in the latest years, I hope you might want to buy me a coffee to show your appreciation. Or sponsor me, if you're a fan.

Open-source software is great for everyone, but it takes passion and time (and coffee!) to grow and evolve.

Thank you for thinking about it.
Have a wonderful day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants