Support » Plugin: Simple Lightbox » [Plugin: Simple Lightbox] Lightbox Max Size Image

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Archetyped



    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.

    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?

    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 750×500 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!



    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.



    That code works without the second bit added.

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

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: Simple Lightbox] Lightbox Max Size Image’ is closed to new replies.