seany123 Posted March 2, 2012 Share Posted March 2, 2012 is it possible to set the MAX height and/or width an image can be inside the <img> tags? eg. <img src="image.php" max-height="40px" max-width="70px"> the idea being that the image stays the normal height+width UNLESS it reaches over the said amounts then it scales down to fit inside the amounts. Quote Link to comment Share on other sites More sharing options...
PravinS Posted March 2, 2012 Share Posted March 2, 2012 set only width or height, don't set both... it will be seen in proportion Quote Link to comment Share on other sites More sharing options...
floridaflatlander Posted March 2, 2012 Share Posted March 2, 2012 The stuff I googled said it could and pbs is right but some people break this rule if the images are small, grouped with other images and they are links to larger images or more info. Quote Link to comment Share on other sites More sharing options...
seany123 Posted March 3, 2012 Author Share Posted March 3, 2012 set only width or height, don't set both... it will be seen in proportion well by setting the height or width its defining the size of the image, i dont want to do that, i want to define the max height or width the image is allowed to be. Quote Link to comment Share on other sites More sharing options...
dannyb785 Posted March 3, 2012 Share Posted March 3, 2012 well by setting the height or width its defining the size of the image, i dont want to do that, i want to define the max height or width the image is allowed to be. You're saying it like you may not have control over the size of the image. If you provide php before any image is displayed, you can always set the max height/width When I do image resize scripts, I always check that the height is less than 600 pixels(to fit in most browsers) and to specify the image width/height, I do the following: // code that gets the current image's width/height and puts into $image_width/$image_height if($image_height > 600) { $r = $image_h / 600; // $r is temporary variable that represents the ratio between the image height and 600 $image_width = $image_width / $r; // that ratio is applied to the width $image_height = $image_height / $r; // and then apply the ratio to the height } // so now $image_width/$image_height are set so that the dimensions are proportional to the original, and so that the height is no greater than 600 modify this code accordingly to fit your needs Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.