Simple Lightbox
[resolved] Lightbox Max Size Image (7 posts)

  1. eaguilar9
    Posted 4 years ago #

    Hello, I was just wondering if there was a way to set a max-width on the lightbox. URL Sample: http://www.thesoundpalace.com/news/recording-continues-for-christmas-cd


  2. Archetyped
    Plugin Author

    Posted 4 years ago #


    Images are displayed at their original size to maintain optimum image quality. Resizing images to their desired display size prior to uploading is recommended.

    This and other usage notes for SLB can be found at SLB's official page.

  3. transparencia
    Posted 4 years ago #

    Archetyped, what about using SLB with the wordpress media sizes (the ones we choose at Settings -> Media), letting the user choose which one or automatically choose the 'large' one.

    We could tell the script to use the 'large' by using this function:

    <?php wp_get_attachment_image_src( $attachment_id, $size = 'large', $icon ); ?>


    This would return an array with the URL, width and height.

    What do you think?

  4. transparencia
    Posted 4 years ago #

    Ok, here's a solution (hack) to limit the images max size that uses the WordPress Media 'Large' size. (Note: You have to make sure that you go go Settings -> Media and set a width and a height on the large field. I use 750x500 and it works great!)

    In /model.php insert this code in line 687 (before "Update Link in Content):

    //Replace the Image URL with the 'large' sized one
    $image_src = $attr['href'];
    $wpdb->query( $wpdb->prepare(" SELECT ID FROM {$wpdb->posts} WHERE guid = %s ", $image_src ) );
    $att_id = $wpdb->get_var($query);
    if ($att_id)
         $image_large_attr = wp_get_attachment_image_src($att_id, 'large');
         $attr['href'] = $image_large_attr[0];

    In line 1092 of /model.php add the text "large" inside the empty apostrophes:

    $d = wp_get_attachment_image_src($att->ID, 'large');

    I'm not a coder and this code is probably not the best but it works!

  5. ericschoeb
    Posted 3 years ago #

    I like this solution, but with the version of the plugin I'm using (1.6.1), I don't see anywhere to edit the wp_get_attachment_image_src() function. I'm assuming you're using an older version of the plugin. If anyone has any additional insight though, it would be much appreciated.

  6. deeve007
    Posted 3 years ago #

    That code works without the second bit added.

  7. bornsupercharged
    Posted 3 years ago #

    Thanks transparencia, it looks like 1.6.2 has it around 834. Adding that code fixed it for me!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Simple Lightbox
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic