NextGEN Gallery
Getting image width and height for html img tag attributes (5 posts)

  1. theorib
    Posted 5 years ago #

    Hi Alex,

    Is there a way to output image width and height for both images and thumbnails in both galleries and albums?

    I would insert the code in the following contexts in the gallery.php and album-extend.php where the ????????? are:

    <a href="<?php echo $gallery->pagelink ?>"><img height="<?php ????????? ?>" width="<?php ????????? ?>" class="Thumb" alt="<?php echo $gallery->title ?>" src="<?php echo $gallery->previewurl ?>"/></a>
    <img title="<?php echo $image->alttext ?>" alt="<?php echo $image->description ?>" height="<?php ????????? ?>" width="<?php ????????? ?>" src="<?php echo $image->thumbnailURL ?>" />
  2. theorib
    Posted 5 years ago #

    Hi, did anyone find out how to solve this?

  3. nrrghh
    Posted 5 years ago #


    also spent time trying to figure this & solved

    & if anyone has a more elegant solution to this basic problem do tell

    inside image.php

    then go to
    function nggImage($gallery) {


    $size = getimagesize($this->thumbURL);
    $this->tt_width		= $size[0];

    you then have a variable with a value to play off

    <li class="<?php if ($image->tt_width > 150 ) {echo 'hthumb';} ?><?php if ($image->tt_width < 150 ) {echo 'vthumb';} ?>">

    & thus can position & style landscape & portrait images



  4. dannylinton
    Posted 5 years ago #

    how would this work? do you have any more detail on this? sorry to be a pain. Im needing to position my image browser based on landscape and portrait photos.

  5. macambulance
    Posted 4 years ago #

    There's an array contained within the $image object called meta_data, you can use echo $image->meta_data['width'] to output the width key from the meta_data array within the $Image object.

    If you use print_r($image) you'll be able to see the full contents of the $image object.

    Hope that helps


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • NextGEN Gallery
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.