| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
#1 (permalink) |
|
Goodbye little old lady
|
php idiot
I'm desperately trying to learn php as I go along I've been trawling through php.net for a couple of weeks and trying to cram as much php into my head as possible. And so, my question - I'm trying to use getimagesize() function I'm trying to get an image and it's width and height returned. I define $brandingimg in each document, and want to have the image and the width and the height returned. I also want a way of putting alt and/or title text - I'm guess I can just put a variable $alt in there and define it in each page. <?php $image = "/i/$brandingimg"; $size = getimagesize("$image"); $height = $size[1]; $width = $size[0]; echo "<img src=\"$image\" height=\"$height\" width=\"$width\" />"; ?> The image is returned fine, but the height and width are empty. Any help would be great |
|
|
|
|
|
#6 (permalink) |
|
Spare Parts
Join Date: Jan 2005
Location: Bracknell Forest
Posts: 4,961
|
<?php $size = getimagesize("/i/".$brandingimg); $image = "/i/$brandingimg"; $height = $size[1]; $width = $size[0]; echo "<img src=\"$image\" height=\"$height\" width=\"$width\" />"; ?> Does this work? |
|
|
|
#7 (permalink) |
|
Spare Parts
Join Date: Jan 2005
Location: Bracknell Forest
Posts: 4,961
|
or <?php $size = getimagesize("/i/$brandingimg"); $image = "/i/$brandingimg"; $height = $size[1]; $width = $size[0]; echo "<img src=\"$image\" height=\"$height\" width=\"$width\" />"; ?> |
|
|
|
#8 (permalink) | |
|
blam blam
Join Date: Aug 2006
Location: ann arbor, mi usa
Posts: 527
|
Quote:
oh yeah!!! i think variables are only evaluated in double-quotes in an echo statement. so this should fix it. nice catch. |
|
|
![]() |