Skip to content

Commit

Permalink
Carousel: Check we can preload an image before attempting it (#40535)
Browse files Browse the repository at this point in the history
* Check if the gallery src is set before using it

* changelog
  • Loading branch information
donnchawp authored Dec 10, 2024
1 parent 3f6eae4 commit c4ce87e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions projects/plugins/jetpack/changelog/fix-carousel-null-request
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

Carousel: Under rare circumstances, the carousel will make null requests when loading an image
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,7 @@
var max = calculateMaxSlideDimensions();

// If the startIndex is not 0 then preload the clicked image first.
if ( startIndex !== 0 ) {
if ( startIndex !== 0 && items[ startIndex ].getAttribute( 'data-gallery-src' ) !== null ) {
var img = new Image();
img.src = items[ startIndex ].getAttribute( 'data-gallery-src' );
}
Expand Down

0 comments on commit c4ce87e

Please sign in to comment.