So - I have this website (Pickture) which allows users to upload a photo of virtually any size.
This causes a headache when it comes to displaying them.
Currently this happens. The Image is inside a container DIV (which I would prefer to be untouched), and is set to a width of 100% and the height is left blank. This means that all images, even if only 200x200, will be scaled to be around 600x600.
What I would like to happen is this. If the width of the image is greater than 650px, set the width to 100%. If the width is less than that, set the width of the image to be the width of the image (actual size).
I was thinking I could probably do this with a combination of jQuery and PHP - PHP to get the dimensions of the image, and jQuery to set the display dimensions based on some variables put in with PHP - eg:
<script type="text/javascript">
var imageWidth = <?php echo 'something';?>
if (imageWidth > 650) {
$('#image').css('width', '100%');
} else {
$('#image').css('width', '<?php echo 'something';?>');
}
</script>
Thanks to anyone who can help me solve this conundrum.