• Resolved LS

    (@lsterling03)


    Is there a function or filter I can use to change the size of the image that is opened in the lightbox? It naturally opens the “full” image size, but that can be a very large file size. I’d prefer to set it to open the “large” image size. Is this possible?

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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);
    Plugin Author Archetyped

    (@archetyped)

    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Change lightbox image size?’ is closed to new replies.