How do i Resizing large image to fit page ?

Discussion in 'PHP' started by procrastinator, Jun 20, 2007.

  1. #1
    im running an image hosting site, for large images it completely ruins page layout ,= , just like imageshack or imagevenue has ..large images come in their orignal size only when they are click on.

    [​IMG]

    [​IMG]
     
    procrastinator, Jun 20, 2007 IP
  2. Free Directory

    Free Directory Peon

    Messages:
    89
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    They are using a onLoad javascript function.
    Put that page in your gallery.php page:
    
    <script language="javascript">
    var saveWidth = 0;
    
    function scaleImg(what){
    what = document.getElementById(what);
    if (navigator.appName=="Netscape")
    winW = window.innerWidth;
    if (navigator.appName.indexOf("Microsoft")!=-1)
    winW = document.body.offsetWidth;
    if (what.width>(720) || saveWidth>(720)) {
    if (what.width==(720))
    what.width=saveWidth;
    
    else
    {
    saveWidth = what.width;
    what.style.cursor = "pointer";
    what.width=(720);
    }
    
    }
    }
    </script>
    
    Code (markup):
    and then, on the image tag(Your example:
    <img src="images/Rani%20Mukherjee-desibabesandhunks.blogspot.com-5234.jpg">
    
    Code (markup):
    , after src="..." add
    id="thepic" onClick="scaleImg('thepic')" onLoad="scaleImg('thepic')"
    Code (markup):
    and you'll have the same facility as imagevenue.

    so, you should have something like that in that file:
    <img src="{YOUR_FILE_LOCATION}" id="thepic" onClick="scaleImg('thepic')" onLoad="scaleImg('thepic')">
    Code (markup):
    Enjoy:)
     
    Free Directory, Jun 20, 2007 IP
    procrastinator likes this.