[eluser]John_Betong[/eluser]
[quote author="slowgary" date="1247892579"][quote author="TheFuzzy0ne" date="1247876863"]This is just a stab in the dark here, but would CSS max-width be of any use here?[/quote]
I don't see any other way. Leave the width and height attributes out of the img tag and just specify a max-width for images depending on the column. The height part will take care of itself.[/quote]
If the image width has a maximum w size of 470px and could be smaller then try:
1. enclosing the images in a predefined div with a width of 470px
2. use the following code to display the image
Code:
<div style='width:470px; text-align:center'>
<img src='<?php echo $image ?>' style='width:<?php echo $width ?>px; margin:auto'>
</div>
Images with a width of less than 470px will be horizontally centered and aligned to the top of the div.
edit: just ran some tests and the previous css code with a width of 100% re-sized the image to fit into the div. This was not wanted so I changed the <img