PDA

View Full Version : attachment image height en width


ageurtse
26 Dec 2009, 14:56
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
05 Jan 2010, 19:48
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
09 Oct 2011, 21:53
Where did you plug this info into to get this to work? In a template, in the attachment.php file???