Add more thumb size and limit number of possible size

This commit is contained in:
Knah Tsaeb 2020-10-12 14:47:41 +02:00
parent 81d87d906c
commit db9b1e0b06
2 changed files with 20 additions and 2 deletions

View file

@ -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

View file

@ -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.
{