Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
fb96bda
Add image prefetching for lightbox images
Takshil-Kunadia Apr 25, 2024
32de3cc
feat: add delay before prefetching
Takshil-Kunadia Jun 17, 2025
1076bd9
docs: update docs
Takshil-Kunadia Jun 17, 2025
4363f5f
fix: track prefetched images to avoid duplicate markup
Takshil-Kunadia Jun 21, 2025
a0ce109
docs: add context comments
Takshil-Kunadia Jun 21, 2025
713eada
feat: implement responsive image preloading for lightbox images
Takshil-Kunadia Jun 22, 2025
d9a2e9f
refactor: rectify approach to accurate name
Takshil-Kunadia Jun 22, 2025
95033e3
fix: remove URL validation
Takshil-Kunadia Jun 24, 2025
b55f573
refactor: relocate srcset assignment for better readability
Takshil-Kunadia Jun 24, 2025
1101ecb
docs: add context comment
Takshil-Kunadia Jun 24, 2025
e9214c2
refactor: address PR feedback — use Map for preload timers, add prelo…
Takshil-Kunadia Jun 24, 2025
d6473eb
refactor: early return for already fetched images
Takshil-Kunadia Jun 24, 2025
702e856
refactor: streamline state logic
Takshil-Kunadia Jun 24, 2025
9fe6406
Revert "refactor: streamline state logic"
Takshil-Kunadia Jun 25, 2025
6858b5e
fix: use dynamic lightboxSizes for imagesizes
Takshil-Kunadia Jun 25, 2025
e41fd23
refactor: use separate fns to extract common logic
Takshil-Kunadia Jun 25, 2025
e007c45
refactor: destructure image metadata parameter
Takshil-Kunadia Jun 26, 2025
a99e61e
refactor: remove redundant lightbox sizes logic
Takshil-Kunadia Nov 3, 2025
1a33ec9
fix: reload tests
Takshil-Kunadia Nov 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "refactor: streamline state logic"
This reverts commit cab1562.
  • Loading branch information
Takshil-Kunadia committed Oct 29, 2025
commit 9fe64061d138591c35e32cfdc3fd5a97cefc8d9c
18 changes: 6 additions & 12 deletions packages/block-library/src/image/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,28 +211,22 @@ const { state, actions, callbacks } = store(
return;
}

// Sets the current image ID to preload.
state.currentImageId = imageId;

// Create link element to preload the image.
// Link element to preload the image.
const imageMetadata = state.metadata[ imageId ];
const imageLink = document.createElement( 'link' );
imageLink.rel = 'preload';
imageLink.as = 'image';
imageLink.href = state.enlargedSrc;
imageLink.href = imageMetadata.uploadedSrc;

// Apply srcset if available for responsive preloading.
const srcset = state.enlargedSrcset;
// Apply srcset if available for responsive preloading
const srcset = imageMetadata.lightboxSrcset;
if ( srcset ) {
imageLink.setAttribute( 'imagesrcset', srcset );
imageLink.setAttribute( 'imagesizes', state.enlargedSizes );
imageLink.setAttribute( 'imagesizes', '100vw' );
}

// Append the link element to the document head to trigger preloading.
document.head.appendChild( imageLink );
state.preloadedImageIds.add( imageId );

// Reset state after preloading the image.
state.currentImageId = null;
},
preloadImageWithDelay() {
const { imageId } = getContext();
Expand Down