Skip to content

Commit

Permalink
allow lazy loading with Lightbox
Browse files Browse the repository at this point in the history
  • Loading branch information
aledesma-godaddy committed Feb 27, 2024
1 parent 72f4162 commit 7bb8401
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/js/coblocks-lightbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,15 @@

// If the src is lazy loaded, use the data-src attribute.
// Compatibility with A3 Lazy Load plugin and maybe others.
if ( img.attributes.src.value?.includes( 'lazy-load' ) ) {
imagePreloader[ `img-${ imgIndex }` ].src = img.attributes[ 'data-src' ].value;
if (
img.attributes.src.value?.includes( 'lazy-load' ) &&
'undefined' !== typeof img.attributes?.[ 'data-src' ]?.value
) {
imagePreloader[ `img-${ imgIndex }` ].src =
img.attributes[ 'data-src' ].value;
} else {
imagePreloader[ `img-${ imgIndex }` ].src = img.attributes.src.value;
imagePreloader[ `img-${ imgIndex }` ].src =
img.attributes.src.value;
}

imagePreloader[ `img-${ imgIndex }` ][ 'data-caption' ] =
Expand Down

0 comments on commit 7bb8401

Please sign in to comment.