PDA

View Full Version : attachment image height en width


ageurtse
12-26-2009, 12:56 PM
I would like to know how to get an attachments height and width. how could i do this.

for displaying the image i use

$output .= "<img border=0 src=attachment.php?attachmentid=".$post['attachmentid']."&thumb=1>";

i put this in a cel from a table. but i would scale the longest size to fit in this cell so it attachment would display normal and not stretcht out.


i think i use
if ($height < $width){$output .= "<img border=0 src=attachment.php?attachmentid=".$post['attachmentid']."&thumb=1 width=100%>";}
else
{$output .= "<img border=0 src=attachment.php?attachmentid=".$post['attachmentid']."&thumb=1 height=100%>";};


but how do i get this width and height

ageurtse
01-05-2010, 05:48 PM
i have solved it myself, see the code below.

function fetch_attachment_info($userid, $attachid, $thumb)
{
$image = fetch_attachment_path($userid, $attachid,$thumb,'');
list($width, $height, $type, $attr) = getimagesize($image);

if ($width<$height ){$scaleh=true;} else { $scaleh=false;}

$attachinfo = array($width,$height,$scaleh);

return $attachinfo ;
}
?>

Budget101
10-09-2011, 07:53 PM
Where did you plug this info into to get this to work? In a template, in the attachment.php file???