From 909133b1b0693a8bf57c5f4fc0d7b28306797fef Mon Sep 17 00:00:00 2001 From: Marc MAURICE Date: Sun, 12 Dec 2010 23:35:15 +0100 Subject: [PATCH] load plugins, and added getThumbTarget function, overloaded by viewer plugin --- index.php | 14 ++++++++++++++ plugins/viewer/functions.php | 6 ++++++ 2 files changed, 20 insertions(+) create mode 100644 plugins/viewer/functions.php diff --git a/index.php b/index.php index 61f5579..b464e04 100644 --- a/index.php +++ b/index.php @@ -19,6 +19,19 @@ require 'config.php'; +// load plugins +$plugins = scandir("plugins"); +array_shift($plugins); array_shift($plugins); // remove . and .. +foreach ($plugins as $p) if (is_file("plugins/$p/functions.php")) + require "plugins/$p/functions.php"; + +if (! function_exists('getThumbTarget')) { +function getThumbTarget($imageSimplePath) +{ + return dirname($_SERVER["SCRIPT_NAME"]).'/'.IMAGES_DIR.$imageSimplePath; +} +} + function getPreview($imgFile, $maxSize = THUMB_SIZE) { # example: data/myalbum/100.mypic.jpg @@ -120,6 +133,7 @@ foreach (scandir($realDir) as $file) if ($file != '.' and $file != '..') $ext = strtolower(substr($file, -4)); if ($ext == ".jpg" or $ext == ".png") { $link = dirname($scriptUrlPath)."/$realDir/$file"; + $link = getThumbTarget("$shortPath/$file"); $imageFiles[] = array( "name" => $file, "url" => getPreview("$realDir/$file"), "link" => $link ); diff --git a/plugins/viewer/functions.php b/plugins/viewer/functions.php new file mode 100644 index 0000000..3d14508 --- /dev/null +++ b/plugins/viewer/functions.php @@ -0,0 +1,6 @@ + -- 1.7.10.4