Alright,
Im using TStarGallery 1.0 engine
the whole code is as follows....
// TStarGallery 1.0 engine
// With basic PHP knowledge you can understand what's happening here.
// Don't blame me for writing non-perfect code for I do not care.
// If there is an error or something, mail me at info@taillandier.de
// Read the current directory, throw out non-jpg/gif/png + thumbfiles
// --------------------------------------------------------------------
$dirfiles = array();
$handle=opendir('.');
while ($file = readdir($handle)) {
if
((
strtolower(strrchr($file, '.')) == ".jpg" OR
strtolower(strrchr($file, '.')) == ".jpeg" OR
strtolower(strrchr($file, '.')) == ".png" OR
strtolower(strrchr($file, '.')) == ".gif"
)
&&
(
strstr($file, ".thumb.jpg") == ''
))
{
array_push($dirfiles, $file);
}
}
sort ($dirfiles);
closedir($handle);
// Write the beginning of the basic table for displaying the thumbs.
// Modify this section to make it fit your own website.
// -----------------------------------------------------------------
echo "<table width=\"100\" border=\"0\" cellpadding=\"1\" cellspacing=\"0\" id=\"structure\"><tr>";
// Read the valid filenames from the array, have your way with every single one of them
// ------------------------------------------------------------------------------------
foreach($dirfiles as $aktuellesfile)
{
// Elements of the filename are cut into pieces
$dateiendung = strrchr( $aktuellesfile, '.' );
$dateiname = substr_replace ($aktuellesfile, '', -strlen($dateiendung) );
// First a routine for creating a thumb
createthumb ($dateiname, $dateiendung);
// Now open up a table cell
echo "<td>";
// Second a routine for showing a thumb
showthumb ($dateiname, $dateiendung);
// Close the table cell
echo "</td>";
// And make a linebreak after every 5 thumbs
if(++$cnt % 5 == 0) echo "</tr>";
}
// Finished
exit;
// Function to create a thumbnail if it doesn't already exist
// -----------------------------------------------------------------
function createthumb ($thumbdateiname, $thumbdateiendung)
{
$fullname = $thumbdateiname.$thumbdateiendung;
$fullthumbname = $thumbdateiname.$thumbdateiendung.".thumb.jpg";
// If thumb exists,nothing will happen
if (file_exists($fullthumbname) OR strstr($fullname, ".thumb.jpg") != '')
{
}
// If thumb doesn't exist,it's created now
else
{
if ((strtolower($thumbdateiendung) == ".jpg") OR (strtolower($thumbdateiendung) == ".jpeg")){
$src_img = imagecreatefromjpeg($fullname);
}
if (strtolower($thumbdateiendung) == ".gif"){
$src_img = imagecreatefromgif($fullname);
}
if (strtolower($thumbdateiendung) == ".png"){
$src_img = imagecreatefrompng($fullname);
}
$origx=imagesx($src_img);
$origy=imagesy($src_img);
// Maximum width and height of the thumbnails
$max_x = 60;
$max_y = 60;
// Calc, if thumb has has to be squeezed from width or height
if($origx >= $origy AND $origx > $max_x)
{
$faktor = $origx / $max_x;
$new_x = $origx / $faktor;
$new_y = $origy / $faktor;
}
elseif($origy > $origx AND $origy > $max_y)
{
$faktor = $origy / $max_y;
$new_x = $origx / $faktor;
$new_y = $origy / $faktor;
}
else
{
$new_x = $origx;
$new_y = $origy;
}
// Squeeze and write it into a file
$dst_img = imagecreatetruecolor($new_x,$new_y);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$new_x,$new_y,imagesx($src_img),imagesy($src_img));
imagejpeg($dst_img, $fullthumbname, 50);
}
}
// Function to show a thumbnail
// -----------------------------------------------------------------
function showthumb ($thumbdateiname, $thumbdateiendung)
{
$fullname = $thumbdateiname.$thumbdateiendung;
$fullthumbname = $thumbdateiname.$thumbdateiendung.".thumb.jpg";
if (file_exists($fullthumbname))
{
echo "<a href=\"$fullname\" target=\"_blank\"><img src =\"$fullthumbname\" border=\"0\"></a>";
}
else
{
}
}
I made a small edit to make the image link open in a blank window. My problem/what I need help with is as follows:
I want to have it set up so when you click the image in the gallery that the image loads into a new window which is the same size as the original image. I tried adding a javascript for a pop up window to the phpcode and its making the popup "pop up" but its just a blank page, its doesnot load the image just gives me an error:
see it in action here: http://www.hpadv.net/area51/imagegallery/test.php
^ this is just the test page
the java script used is:
<script type="text/javascript">
function obrazek(url, width, height){ var windowX = Math.ceil( (window.screen.width-width) / 2 ); var windowY = Math.ceil( (window.screen.height-height) / 2 ); var Win = window.open(url,"",'width=' + width + ',height=' + height + ',resizable=0,scrollbars=yes,menubar=no' ); Win.moveTo ( Math.ceil( windowX ) , Math.ceil( windowY ) ); }
</script>
intrun I also made edits to the php part of the code for the link on the thumbs which now looks like:
// Function to show a thumbnail
// -----------------------------------------------------------------
function showthumb ($thumbdateiname, $thumbdateiendung)
{
$fullname = $thumbdateiname.$thumbdateiendung;
$fullthumbname = $thumbdateiname.$thumbdateiendung.".thumb.jpg";
if (file_exists($fullthumbname))
{
echo "<a href=\"javascript:obrazek('../imagegallery/$fullname',800,600)\" target=\"_blank\"><img src =\"$fullthumbname\" border=\"0\"></a>";
}
else
{
}
}
?>
Can someone help me out? I just need help loading the new window with the original image inside it and have it the same size of the picture.
thanks!