Skip to content

Commit 7f29154

Browse files
committed
FEAT: added no-JS screenshot link fallback
- Wrapped each <img> in build_image_block() with an <a href="{src}" target="_blank" rel="noopener"> so the no-JS reader still gets a path to the full-resolution screenshot in a new tab. - Core's lightbox interactivity script attaches its own click handler on hydration and calls preventDefault() before the anchor would navigate, so JS readers keep the existing lightbox flow unchanged. Affected: wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-screenshots.php
1 parent 6af7759 commit 7f29154

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-screenshots.php‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,18 @@ protected static function build_image_block( $screenshot, $id, $above_fold = fal
364364
// available without delaying the first paint.
365365
$priority = $above_fold ? 'high' : 'low';
366366

367+
// Wrap the `<img>` in an `<a href="{src}" target="_blank">` so
368+
// the no-JS reader still gets a path to the full-resolution
369+
// screenshot (opens in a new tab). Core's lightbox interactivity
370+
// script attaches its own click handler on hydration and calls
371+
// `preventDefault()` before the anchor would navigate, so JS
372+
// readers keep the existing lightbox flow unchanged — the link
373+
// is a pure progressive-enhancement fallback.
367374
$figure = '<figure class="' . esc_attr( $class ) . '">';
375+
$figure .= sprintf(
376+
'<a href="%1$s" target="_blank" rel="noopener">',
377+
$src
378+
);
368379
$figure .= sprintf(
369380
'<img src="%1$s" alt="%2$s" class="wp-image-%3$d"%4$s%5$s loading="eager" fetchpriority="%6$s" decoding="async"/>',
370381
$src,
@@ -374,6 +385,7 @@ protected static function build_image_block( $screenshot, $id, $above_fold = fal
374385
$dim_attrs,
375386
esc_attr( $priority )
376387
);
388+
$figure .= '</a>';
377389

378390
if ( '' !== $caption ) {
379391
$figure .= sprintf(

0 commit comments

Comments
 (0)