• Michael D

    (@michael-divine)


    I’d like to generate a div around an image in the imagebrowser that is the same size as the image being displayed like this:

    <div style="height:[image height];width:[image width]>
    <img src="<?php echo $image->imageURL ?>" alt="<?php echo $image->alttext ?>"height=[image height] width="[image width]" />
    </div>

    I’ve tried various iterations of stuff like this:

    width="<?php echo $thumb_size->width ?>" height="<?php echo $thumb_size->height ?>"

    The heights and widths of the images in the gallery vary so I can’t just make it the same. The image itself is already in a container div but the container is the same size on each page. The reason I want to do this is that I want an overlay window when the user hovers over the image. The hover window would be only 80% of the height and width of the image. Thus, I need the dimensions of the image for the container div so the hover window is properly contained.

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Anonymous User 9105421

    (@anonymized-9105421)

    I’m not sure what the image-browser is but the file “/admin/manage/class-ngg-gallery-list-table.php” which creates the view of the separate galleries in the wp-admin section of NextCellent Gallery uses these:

    1. to get the width of the image:
    
    <?php echo $item->meta_data['width'] ?>
    
    2. to get the height of the image
    
    <?php echo $item->meta_data['height'] ?>
    Thread Starter Michael D

    (@michael-divine)

    Thanks! Though that wasn’t quite it, it pointed me in the right direction.

    $image rather than $item

    So this now outputs the image within a div the same size as the image.

    <div class="pic" style="width:<?php echo $image->meta_data['width']; ?>px; height:<?php echo $image->meta_data['height']; ?>px;">
    	<img class="imagebrowserpic" src="<?php echo $image->imageURL ?>" alt="<?php echo $image->description ?>" /> 

    Also, I had meant imagebrowser.php – the template for showing a single image from a gallery.

    Anonymous User 9105421

    (@anonymized-9105421)

    OK glad to my input helped to point you in the right direction.

    Then thread can be marked as solved i suppose =)

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Get Image height and width in Imagebrowser’ is closed to new replies.