WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. theorib
    Member
    Posted 3 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
    Member
    Posted 3 years ago #

    Hi, did anyone find out how to solve this?

  3. nrrghh
    Member
    Posted 3 years ago #

    hi

    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) {

    add

    $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

    enjoy

    Mark

  4. dannylinton
    Member
    Posted 3 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
    Member
    Posted 2 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

    Sam

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.