diff --git a/config-default.php b/config-default.php index 787f8d1..c76c416 100755 --- a/config-default.php +++ b/config-default.php @@ -40,6 +40,7 @@ $keep_extensions = array('jpg', 'jpeg', 'png', 'gif'); //Files with one of this //ADVANCED SETTINGS $thumb_size = 320; // Thumbnail height/width (square thumbs). Changing this will most likely require manual altering of the template file to make it look properly! +$thumb_size_limit = array(320, 160, 80); // Limit possible thumb size prevent space in server $label_max_length = 40; // Maximum chars of a folder name that will be displayed on the folder thumbnail $display_exif = 0; // Take care, even if not diplayed EXIF are still readable for visitors. May be a good idea to erase EXIF data... $display_filename = 0; // Show file names below the pictures diff --git a/createthumb.php b/createthumb.php index 402e03f..6f9e3da 100644 --- a/createthumb.php +++ b/createthumb.php @@ -9,10 +9,27 @@ error_reporting(0); +require "config-default.php"; +if(file_exists('config.php')){ + include "config.php"; +} + $get_filename = $_GET['filename']; $get_size = @$_GET['size']; if (empty($get_size)) { - $get_size = 120; + $get_size = $thumb_size; +} + +$options = array( + 'options' => array( + 'default' => $thumb_size, + ) +); + +$get_size = filter_var($get_size, FILTER_VALIDATE_INT, $options); + +if(!in_array($get_size, $thumb_size_limit)){ + $get_size = $thumb_size; } if (preg_match("/^\/.*/i", $get_filename)) { @@ -77,7 +94,7 @@ if (!is_dir('thumbs') && is_writable('.')) { // Thumbnail file name and path. // (We always put thumbnails in jpg for simplification) -$thumbname = 'thumbs/' . sanitize($get_filename) . '.jpg'; +$thumbname = 'thumbs/' . sanitize($get_size.'_'.$get_filename) . '.jpg'; if (file_exists($thumbname)) // If thumbnail exists, serve it. {