Page 1 of 1

gallery help

Posted: Thu Dec 17, 2009 11:58 am
by regularguy
Hi,
somebody send me this script (below) to make gallery for my site, it works well!
I just wondering, if some one can help me on how to make clicked thumbs open (the big picture) on the new windows?
.... click the big picture back to the thumbs? or new template windows?
THANKS. and happy holidays !!!!!!!!

<?php
error_reporting(E_ALL);
if(!is_dir('thumbs')) die('thumbs directory was not found');
$file_list = array();

if ($handle = opendir('thumbs')) {
while (false !== ($file = readdir($handle))) {
if (strtolower(array_pop(explode('.',$file))) == 'jpg') {
$file_list[] = $file;
}
}
closedir($handle);
}

$count = 0;
$total = count($file_list);
?>

<?php

sort($file_list);
foreach($file_list as $file) {
$path = 'thumbs/'.$file;
if(!is_file($file)) continue;
echo "<a href=\"{$file} \"><img src=\"{$path}\" class=\"pic\" alt=\"{$file}\"></a>
";
}

?>

Re: gallery help

Posted: Thu Dec 17, 2009 12:12 pm
by AbraCadaver
target="_blank" to open in a new window. I don't know about the other because you will already have the thumbs open in the first window.

Code: Select all

echo "<a href=\"{$file}\" target=\"_blank\"><img src=\"{$path}\" class=\"pic\" alt=\"{$file}\"></a>
 

Re: gallery help

Posted: Fri Dec 18, 2009 3:28 pm
by regularguy
That's give me some ideas!
THANKS !

Re: gallery help

Posted: Fri Dec 18, 2009 4:34 pm
by daedalus__
OHHHHHHHH

hey. use javascript to open a div with the selected image in it. that way you can style it make it pretty and apply scripts to it. opening a new window is so ugly :(

Re: gallery help

Posted: Fri Dec 18, 2009 5:11 pm
by AbraCadaver
daedalus__ wrote:OHHHHHHHH

hey. use javascript to open a div with the selected image in it. that way you can style it make it pretty and apply scripts to it. opening a new window is so ugly :(
Good point daedalus__! Just answering the question.

Re: gallery help

Posted: Fri Dec 18, 2009 5:13 pm
by daedalus__
well that might be a little above his skill level but a good idea for the future

Re: gallery help

Posted: Fri Dec 18, 2009 6:46 pm
by AbraCadaver
Myself, I would probably link to a PHP file that outputs the img tag with whatever HTML I wanted though. And use the class for style:

Code: Select all

echo '<a href="show_image.php?image='.$file.'" target="_blank"><img src="'.$path.'" class="pic" alt="'.$file.'"></a>'; 

Re: gallery help

Posted: Fri Dec 18, 2009 9:55 pm
by regularguy
Hey,
You right that is above my level.
I just learning here, what can I say I'm 56 year old just start to learn php... just the regular guy.
I can't even figure it out to sort the photo so the new one will be on top... almost discouraging this php is.

Thanks for helps, this is a good forum and good people.

Re: gallery help

Posted: Fri Dec 18, 2009 10:07 pm
by AbraCadaver
regularguy wrote:Hey,
You right that is above my level.
I just learning here, what can I say I'm 56 year old just start to learn php... just the regular guy.
I can't even figure it out to sort the photo so the new one will be on top... almost discouraging this php is.

Thanks for helps, this is a good forum and good people.
Don't ever get discouraged. Work at it and come here if you need help.