Thread Starter
LS
(@lsterling03)
I found an answer here: https://oikos.digital/2011/09/tech-notes-using-resized-images-in-wordpress-galleries-and-lightboxes/
This is WP-specific function, not Simple Lightbox. It changes the media link for WP galleries to open the large size of the image instead of the full size:
function my_get_attachment_link_filter( $content, $post_id, $size, $permalink ) {
// Only do this if we're getting the file URL
if (! $permalink) {
// This returns an array of (url, width, height)
$image = wp_get_attachment_image_src( $post_id, 'large' );
$new_content = preg_replace('/href=\'(.*?)\'/', 'href=\'' . $image[0] . '\'', $content );
return $new_content;
}
}
add_filter('wp_get_attachment_link', 'my_get_attachment_link_filter', 10, 4);
Hi, glad to hear you found a solution for what you wanted to do!
SLB currently displays the actual image being linked to, but there are plans to display a smaller version for attachments (when available), if the original image is larger than the browser window.