Skip to content

Refactoring of replacement behavior

Compare
Choose a tag to compare
@fhopeman fhopeman released this 06 Nov 21:32
· 14 commits to master since this release
  • replacement occurs not directly after the construction of the image, but within the onload or onerror callback of the image itself.
  • The custom onloadCallback and onerrorCallback will be invoked immediately before the replacement, so you can add some classes or do some other stuff.
  • The onreplaceCallback will be invoked after the actual replacement.
  • The advantage is, that the placeholder can hold the styling of the lazy image (e.g. the spinner) and is not deleted until the image is completely loaded.

Migration:

  • Check your onerrorCallback: It's no longer for the missing data-src and data-alt attribute. With this callback you can define the action if the image could not be loaded properly.
  • The data-onerror-handler doesn't exist anymore. Please use the onerrorCallback instead.
  • Check the styling and position of your spinner. The styling can be placed on the placeholder itself and will be removed after the image is loaded in the background.