Page 1 of 1

Auto thumbs image gallery

Posted: Thu Sep 19, 2013 4:10 am
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

[syntax=php]<?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>[/syntax]

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

Re: Auto thumbs image gallery

Posted: Thu Sep 19, 2013 5:01 am
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.

Re: Auto thumbs image gallery

Posted: Fri Sep 20, 2013 1:35 am
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

Re: Auto thumbs image gallery

Posted: Fri Sep 20, 2013 3:43 am
by ScTech
As of PHP version 5.2.3, read errors were downgraded to notice level. Try displaying everything.
[syntax=php]
error_reporting(E_ALL);
ini_set('display_errors', 1);[/syntax]