SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Random Thumbnail Generator and clicks for full-size

    Hey guys and girls,

    I'm working on a new site where I would like to have a gallery of photos incorporated into my PHP website. Eventually I would like to have a gallery within my pages... but for now I'm merely looking for a small system where I can upload the original files (500 pixels on the long side, 100kbs max) into a specified folder on the website.

    From that folder, I would like a thumbnail to be automatically generated at random and displayed on the right hand side of every page (with a max width of 80 pixels and max height of 80 pixels.. whichever is longer). I'm planning to have it as part of a PHP include for the entire right side. When that image is displayed, I would like the user to be able to click it and have it load into a new window by itself with no toolbars or scroll bars and have it automatically size to the image dimensions.

    You can view the website at: http://www.camphuronda.ca

    I searched Google, Sitepoint and Hotscripts but couldn't find exactly what I was looking for. The closest I came was a combination of PHP and Javascript but I would like to avoid the Javascript if I could.

    Code:
    SCRIPT>
    
    // SETUPS:
    // ===============================
    
    // Set the horizontal and vertical position for the popup
    
    PositionX = 100;
    PositionY = 100;
    
    // Set these value approximately 20 pixels greater than the
    // size of the largest image to be used (needed for Netscape)
    
    defaultWidth = 500;
    defaultHeight = 500;
    
    // Set autoclose true to have the window close automatically
    // Set autoclose false to allow multiple popup windows
    
    var AutoClose = true;
    
    // Do not edit below this line...
    // ================================
    if (parseInt(navigator.appVersion.charAt(0))>=4){
    var isNN=(navigator.appName=="Netscape")?1:0;
    var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
    var optNN='scrollbars=no,width='+defaultWidth+',height ='+defaultHeight+',left='+PositionX+',top='+Positi onY;
    var optIE='scrollbars=no,width=150,height=100,left='+P ositionX+',top='+PositionY;
    function popImage(imageURL,imageTitle){
    if (isNN){imgWin=window.open('about:blank','',optNN); }
    if (isIE){imgWin=window.open('about:blank','',optIE); }
    with (imgWin.document){
    writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
    writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
    writeln('isNN=(navigator.appName=="Netscape")?1:0; ');writeln('isIE=(navigator.appName.indexOf("Micro soft")!=-1)?1:0;}');
    writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
    writeln('width=100-(document.body.clientWidth-document.images[0].width);');
    writeln('height=100-(document.body.clientHeight-document.images[0].height);');
    writeln('window.resizeTo(width,height);}');writeln ('if (isNN){');
    writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.ima ges["George"].height;}}');
    writeln('function doTitle(){document.title="'+imageTitle+'";}');writ eln('</sc'+'ript>');
    if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
    else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.focus()">');
    writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');
    close();
    }}
    
    </SCRIPT>
    
    <?php
    $total = "11";
    $file_type = ".gif";
    $image_folder = "xxxxxxx/xxxxxxx/random";
    $start = "1";
    $random = mt_rand($start, $total);
    $image_name = $random . $file_type;
    echo "<A
    href=\"javascript:popImage('/$image_folder/large/$image_name','Random Image')\"><img src=\"$image_folder/$image_name\" alt=\"Random Image\" border=0 /></A>";
    
    ?>
    Remember I would like the folder on my server that is being used for the main photos in this gallery to be compatible with whatever I am going to use for a gallery in the future on the web page, so any that tie together would be most excellent.

    Please try to keep in mind that I am still in the early stages of learning my PHP but am quickly getting the hang of it.

    Thanks a lot in advance if you are able to help out.
    Last edited by mikejl29; Jun 6, 2007 at 10:29. Reason: Forgot URL

  2. #2
    SitePoint Wizard wonshikee's Avatar
    Join Date
    Jan 2007
    Posts
    1,223
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    although you want to avoid javascript, if you want a popup the way a thumbnail should popup, javascript is probably the easiest solution.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •