Image max width

Discussion in 'Programming' started by nigeps, Feb 26, 2007.

  1. #1
    I need to shrink images over the size of 700px to 700px, while leaving images under that size untouched.

    My current image display code is as follows:

    <a href="<?php echo $fileurl; ?>"><img src="<?php echo $fileurl; ?>" alt="<?php echo $filename; ?> title="<?php echo $filename; ?>" /></a>


    Can anyone suggest a good way to do this?
     
    nigeps, Feb 26, 2007 IP
  2. Your Content

    Your Content Banned

    Messages:
    1,096
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Easy, just add width:

    In which width is 100% the size of the browser's window or set your own scale but in percentage ;)
     
    Your Content, Feb 26, 2007 IP
  3. wmtips

    wmtips Well-Known Member

    Messages:
    601
    Likes Received:
    70
    Best Answers:
    1
    Trophy Points:
    150
    #3
    You can use getimagesize function to determine width and height of the image, and if they are greater than 700, you need to scale image (imagecopyresampled) or embed <img width=XX height=YY> attributes (but in such case you will have more bandwidth usage because image will be downloaded fullsized and resized by the browser).
     
    wmtips, Feb 27, 2007 IP