diff --git a/lib/block-supports/behaviors.php b/lib/block-supports/behaviors.php index 28b097c8f60449..5f6c72e52199e3 100644 --- a/lib/block-supports/behaviors.php +++ b/lib/block-supports/behaviors.php @@ -141,7 +141,7 @@ function gutenberg_render_behaviors_support_lightbox( $block_content, $block ) { $img = null; preg_match( '/]+>/', $body_content, $img ); $button = '
- ' + ' . $img[0] . '
'; $body_content = preg_replace( '/]+>/', $button, $body_content ); diff --git a/packages/block-library/src/image/view-interactivity.js b/packages/block-library/src/image/view-interactivity.js index e5b8858f10205a..441810a9f2270b 100644 --- a/packages/block-library/src/image/view-interactivity.js +++ b/packages/block-library/src/image/view-interactivity.js @@ -133,6 +133,16 @@ store( { } } }, + preloadLightboxImage: ( { context } ) => { + if ( ! context.core.image.preloadInitialized ) { + context.core.image.preloadInitialized = true; + const imgDom = document.createElement( 'img' ); + imgDom.setAttribute( + 'src', + context.core.image.imageUploadedSrc + ); + } + }, }, }, }, @@ -171,18 +181,6 @@ store( { } ); } }, - preloadLightboxImage: ( { context, ref } ) => { - ref.addEventListener( 'mouseover', () => { - if ( ! context.core.image.preloadInitialized ) { - context.core.image.preloadInitialized = true; - const imgDom = document.createElement( 'img' ); - imgDom.setAttribute( - 'src', - context.core.image.imageUploadedSrc - ); - } - } ); - }, initLightbox: async ( { context, ref } ) => { context.core.image.figureRef = ref.querySelector( 'figure' );