Auto thumbs image gallery

Post here is you are having problems with any of the tutorials.
Post Reply
Romulas
Posts: 24
Joined: Mon Sep 12, 2011 3:59 am

Auto thumbs image gallery

Post by Romulas »

Hi
Some time ago, on your youtube site there was an auto image gallery tutorial. I decided to give it a try. My first attempt was on windows. Since then i have migrated to Linux and have found that this script does not work. So, i started from the beginning and this is where i am up to
<?php
        if (isset($_GET['img'])){
           if (file_exists($_GET['img'])){
		 ignore_user_abort(true);
                set_time_limit(120);
                ini_set('memory_limit', '512M');
                  
               $src_size = getimagesize($_GET['img']);
                   
              if ($src_size === false){
                 die('Not an Image.');
 		}
              $thumb_width   = 250;
              $thumb_height  = 200;
    
              print_r($src_size);
           }
         die();
}

 if (is_dir('./thumbs') === false){
            mkdir('./thumbs', 0744);
    }
   
    $images = glob('*.{jpg,jpeg,png,gif}', GLOB_BRACE);
     
    ?>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style type="text/css">
            a, img {float:left;}
            </style>
    </head>
     
    <body>
    <div> 
    <?php
     
    foreach($images as $image){
            if (file_exists("./thumbs/{$image}")){
                    echo "<a href=\"\"><img src=\"thumbs/{$image}\" alt=\"{$image}\" /></a>";
            }else{
                    echo "<a href=\"\"><img src=\"?img={$image}\" alt=\"{$image}\" /></a>";
            }
         }
      ?>
    </div>
   <body>
 </html>
According to the vid the output of the print_r($src_size); returns an array of the image, well that does not happen, i just get a blank
page. Having noticed that the "?img=" does not appear in the url i added it, eg ?img=picture.jpg but still nothing displays.

I can not see anything that is wrong with my code, hopefully another set of eyes will help

Thanks in advance for you help
ScTech
Posts: 92
Joined: Sat Aug 24, 2013 8:40 pm

Re: Auto thumbs image gallery

Post by ScTech »

Interesting. Are you sure that the file exists? By your example, that means that picture.jpg would be in the same directory as the script. If the file does not exist you have it set to die with no output.
<?php while(!$succeed = try()); ?>
Romulas
Posts: 24
Joined: Mon Sep 12, 2011 3:59 am

Re: Auto thumbs image gallery

Post by Romulas »

I am absolutely sure the file is in the same dir as the script. I was thinking it maybe has something to with Linux, i could be wrong.
This script worked in windows
Thanks ScTech
ScTech
Posts: 92
Joined: Sat Aug 24, 2013 8:40 pm

Re: Auto thumbs image gallery

Post by ScTech »

As of PHP version 5.2.3, read errors were downgraded to notice level. Try displaying everything.
error_reporting(E_ALL);
ini_set('display_errors', 1);
<?php while(!$succeed = try()); ?>
Post Reply