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.
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>
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.'" />';