[Plugin: NextGEN Gallery] extend imagebrowser tag (4 posts)

  1. David Radovanovic
    Posted 7 years ago #

    It's bad way to display images (resizing via css) so I'd like to be able to add an additional variable to the tag that will controls height and width; i.e. [ imagebrowser id=x h=200 w=300 ] so that the GD or imagemagick is used to resize and the page loads faster and the img src is properly structured, e.g. <img src="thumbs_IMG_2431.JPG" width="75" height="50" title="IMG_2431.JPG"
    alt="IMG_2431.JPG" />

    Any ideas?


  2. dotherightthing
    Posted 7 years ago #

    Hi dpaule,

    I wanted the imagebrowser functionality, so this is what I did:

    In /nggallery/lib/shortcodes.php - uncomment the two lines after:
    // do_shortcode on the_excerpt could causes several unwanted output. Uncomment it on your own risk

    Now you can use the shortcodes in your PHP code.

    So in this case you can copy the singlepic shortcode into the imagebrowser template.

    In this case I first added the imagebrowser shortcode to my gallery template, /themes/mytheme/nggallery/gallery-mytemplate.php:

    $img_id = 1; // id of the pic you'd like to display
    echo do_shortcode('[imagebrowser id="' . $img_id . '"  template="mytemplate"]');

    Then I added the singlepic shortcode to my imagebrowser template, /themes/mytheme/nggallery/imagebrowser-mytemplate.php,


    <div class="pic"><?php echo $image->href_link ?></div>


    <div class="pic"><?php echo do_shortcode('[singlepic id="' . $image->pid . '" h="321"]'); ?></div>

    I'm not sure how to dynamically pull the image width, so what I am doing is setting only the height dimension. This forces the browser to render the proportionate width. Not sure if there are any cross-browser issues here but it looked ok to me in Firefox 3.5, IE6 (Multi IE) and IE8.



  3. dotherightthing
    Posted 7 years ago #

    To get the dimensions you set in your NextGen options:

    I'll let you know if I find out how to get the dimensions of a particular image (to check whether it is landscape or portrait).


  4. dotherightthing
    Posted 7 years ago #

    Update: I was passing the image ID to the page via the URL in order to set the default imagebrowser image, but I found that this failed when the ID was > 2. Note sure what is going on here.

    The imagebrowser urls are pretty crazy though, so I might try to code this functionality into the singlepic template.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.