Hallo,
vielleicht kennt der ein oder andere das Plugin für Wordpress? Mein Problem ist, ich möchte diese Gallery in die Seite als einen Menüpunkt einbauen. (Normalerweise ist die Gallery eine eigene Seite.) Das Einbauen habe ich soweit hinbekommen und auch die Bilder werden als Thumbnail angezeigt, nur wenn man auf eins klickt landet man immer auf der Startseite (index.php). Was muss ich hier im Script ändern?
Meine Seite hat die
ID ?page_id=4
Das Script:
PHP-Code:
<?php
// Globals - Do not tamper with these
global $gallery_root, $gallery_address, $file, $excluded_folders, $pictwidth, $pictheight, $thumbwidth, $thumbheight, $gallery_width, $gallery_sidebar;
// ---------- Settings ----------
// Configure these settings, to use the gallery.
// Your gallery folder (this is where your pictures and picture folders are located).
$gallery_address = '/daniel/wp-gallery/';
// Sidebar position
$gallery_sidebar = 'right'; // left or right
// Add foldernames to exclude. (add more lines like this on more excludes.)
$excluded_folders[] = 'cgi-bin';
// Picture size
$pictwidth = 400;
$pictheight = 400;
// Thumbnail size
$thumbwidth = 110;
$thumbheight = 110;
// ---------- Settings end ----------
// Do not edit below this line
$gallery_root = $_SERVER['DOCUMENT_ROOT'].$gallery_address;
$gallery_address = 'http://'.$_SERVER['HTTP_HOST'].$gallery_address;
function showGallery() {
global $file;
if (!validateFile())
{
echo 'Invalid folder or file';
return;
}
createNavigation();
$path = pathinfo($file);
if ($path['extension'] == '')
{
//Display Dir(s) (if any)
showDirs();
//Display Thumb(s) (if any)
showThumbs();
} else {
showSlide($file);
}
}
function setCurrentdir()
{
global $currentdir, $file;
$path = pathinfo($file);
if ($path['extension'] != '')
$currentdir = $path['dirname'].'/';
else
$currentdir = $file;
}
function showDirs() {
global $gallery_root, $currentdir, $file, $excluded_folders;
$runonce = false;
if ($dir_content = opendir($gallery_root.$currentdir)) {
while ( false !== ($dir = readdir($dir_content)) ) {
if (is_dir($gallery_root.$currentdir.$dir) && !in_array($dir, $excluded_folders) && $dir!='.' && $dir!='..' ) {
if ( !$runonce ){
echo '<div class="folders"><br/>Bilderordner:<br/>';
$runonce = true;
}
echo '<a href="'.$_SERVER['PHP_SELF'].'?file='.$currentdir.$dir.'/">» '.$dir.'</a><br>';
}
}
}
if ( $runonce )
echo '</div><br/>';
}
function showSlide($slidefile) {
global $gallery_root, $gallery_address, $currentdir, $file;
if ($dir_content = opendir($gallery_root.$currentdir)) {
while ( false !== ($img = readdir($dir_content)) ) {
if ( is_file($gallery_root.$currentdir.$img) && eregi(".*(\.jpg|\.gif|\.png|\.jpeg)", $img))
$imgfiles[] = $img;
}
}
$prev = '';
$slide = '';
$next = '';
$arraysize = count($imgfiles);
for ($i=0; $i < $arraysize; $i++)
{
if($currentdir.$imgfiles[$i] == $slidefile)
{
$slide = $imgfiles[$i];
// Set prev
if($i==0)
$prev = $imgfiles[$arraysize-1];
else
$prev = $imgfiles[$i-1];
// Set Next
if($i+1 == $arraysize)
$next = $imgfiles[0];
else
$next = $imgfiles[$i+1];
}
}
// Get picture info
$img = $gallery_root.$currentdir.$slide;
$path = pathinfo($img);
switch(strtolower($path["extension"])){
case "jpeg":
case "jpg":
$img=imagecreatefromjpeg($img);
break;
case "gif":
$img=imagecreatefromgif($img);
break;
case "png":
$img=imagecreatefrompng($img);
break;
default:
break;
}
$xsize = (imagesx($img));
$ysize = (imagesy($img));
imagedestroy($img);
echo '<div id="nav">
<a href="'.$_SERVER['PHP_SELF'].'?file='.$currentdir.$prev.'" class="alignleft">« Prev</a>
<a href="'.$_SERVER['PHP_SELF'].'?file='.$currentdir.$next.'" class="alignright">Next »</a>
</div>
<br/>
<div class="image"><a href="'.$gallery_address.$currentdir.$slide.'" target="_new"><img src="./wp-content/plugins/lazy-gallery/lazy-img.php?file='.$currentdir.$slide.'&thumb=0"></a>
</div>
<br/>
<div class="imgdata">
Image data<br/>
Actual size: '.$xsize.' x '.$ysize.'<br/>
</div>';
}
function showThumbs() {
global $gallery_root, $currentdir, $file, $thumbwidth, $thumbheight;
if ($dir_content = opendir($gallery_root.$currentdir)) {
while ( false !== ($file = readdir($dir_content)) ) {
if ( is_file($gallery_root.$currentdir.$file) )
if(eregi(".*(\.jpg|\.gif|\.png|\.jpeg)", $file))
$imgfiles[] = $file;
}
}
echo '<div class="image">';
if(isset($imgfiles))
{
foreach ($imgfiles as $img)
{
//echo '<div style="position: relative; width: '.($thumbwidth+16).'px; height: '.($thumbheight+16).'px; border: 1px solid #a9a9a9;">';
echo '<a href="'.$_SERVER['PHP_SELF'].'?file='.$currentdir.$img.'"><img src="./wp-content/plugins/lazy-gallery/lazy-img.php?file='.$currentdir.$img.'&thumb=1"></a>';
//echo '</div>';
}
}
echo '</div>';
}
// Validates file variable
function validateFile() {
global $excluded_folders, $file;
$file = $_GET['file'];
// validate dir
if ( strstr($file, '..') || strstr($file, '%2e%2e') )
return false;
foreach ($excluded_folders as $folder)
{
if ( strstr($file, $folder) )
return false;
}
setCurrentdir();
return true;
}
function createNavigation()
{
global $currentdir, $file;
if ($currentdir == './')
$currentdir = '';
$nav = split('/', $currentdir);
array_pop($nav);
$path = pathinfo($file);
echo '<div>Aktuelles: » <a href="'.$_SERVER['PHP_SELF'].'">Gallery</a> ';
foreach ($nav as $n)
{
$current .= $n.'/';
echo '» <a href="'.$_SERVER['PHP_SELF'].'?file='.$current.'">'.$n.'</a> ';
}
if ($path['extension']!='')
echo '» <a href="'.$_SERVER['PHP_SELF'].'?file='.$current.$path['basename'].'">'.$path['basename'].'</a>';
echo '</div>';
}
?>