Sat, 2010-03-06 05:25
This may not be a CSS question, but I'm using variables to determine height and width of an image with in a PHP file.
$height = 330;
$width = 270;
I'd like to set those as max-height and max-width so smaller images aren't stretched.
Sat, 2010-03-06 05:34
#1
Don't exactly know why
Don't exactly know why max-height and max-width don't work just within the code itself, but here is the code I'm referring to. It's a WordPress theme:
<a href="<?php echo($arr[$i]["permalink"]); ?>" title="<?php printf(__('Permanent Link to %s', 'TheCorporation'), $arr[$i]["fulltitle"]) ?>"> <?php print_thumbnail($arr[$i]["Feature"], $arr[$i]["use_timthumb"], $arr[$i]["fulltitle"] , $width, $height, 'thumb'); ?> </a>
Sat, 2010-03-06 13:42
#2
query the image to get its
query the image to get its dimensions then determine exact height and width values.
$img = getimagesize('path/to/image'); list($w,$h) = $img; // compare $w & $h to max width and max height and determine what actual width and height to use ... echo '<img src="url/of/image" alt="" width="'.$width.'" height="'.$height.'" />';