diff --git a/module/gallery/gallery.php b/module/gallery/gallery.php index b9055b83..6d511a86 100644 --- a/module/gallery/gallery.php +++ b/module/gallery/gallery.php @@ -41,7 +41,37 @@ class gallery extends common { const GALLERY_VERSION = '2.0'; +// ************* Mofifié par @bruno ************** +// **************** le 04/02/2020 **************** + private $width_thumb = 300; // Largeur des miniatures crées. hauteur respectant le ratio de image originale + public function IsDir_or_CreateIt($path) { + if (is_dir($path)) { + return true; + } else { + if (mkdir($path)) { return true; } + else { return false; } + } + } + + public function CopyDir($origine, $destination) { + $test = scandir($origine); + foreach($test as $val) { + if($val!="." && $val!="..") { + if(is_dir($origine."/".$val)) { + CopyDir($origine."/".$val, $destination."/".$val); + IsDir_or_CreateIt($destination."/".$val); + } + } + } + return true; + } + + public function fix_strtolower($str){ + if (function_exists( 'mb_strtoupper' )) { return mb_strtolower($str); } + else { return strtolower($str); } + } +// *********************************************** public function filter() { // Traitement du tri @@ -303,11 +333,41 @@ class gallery extends common { // La galerie existe else { // Images de la galerie + $need_dir = true; // Si besion de créer des miniatures, recrée si besion l'arborescence du/des répertoires. $directory = $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'config', 'directory']); if(is_dir($directory)) { $iterator = new DirectoryIterator($directory); foreach($iterator as $fileInfos) { if($fileInfos->isDot() === false AND $fileInfos->isFile() AND @getimagesize($fileInfos->getPathname())) { + $rp = realpath($fileInfos->getPathname()); + $tp = str_replace("source", "thumb", $rp); + if (is_readable($tp)) { + $info = pathinfo($tp); + if (in_array(strtolower($info['extension']), array( 'jpg', 'jpeg', 'png' ))) { + $gis = getimagesize("$tp"); + if ($gis[0]<$this->width_thumb) { $need_resize = true; } + else { $need_resize = false; } + } + } + else { $need_resize = true; } + if ($need_resize) { + if ($need_dir) { + $dir = dirname($tp); + $p = explode ( "thumb" , $dir); + if (!is_dir($dir)) { // Création de TOUT les dossiers et sous dossiers + $p = explode ( "thumb" , $dir); + CopyDir("$p[0]source", "$p[0]thumb"); + $need_dir = false; + } + } + $_SESSION['RF']["verify"] = "RESPONSIVEfilemanager"; // Pour éviter un forbiden dans la face + @require_once("core/vendor/filemanager/include/utils.php"); // Désolé pour @, pour éviter les erreurs + require_once("core/vendor/filemanager/include/php_image_magician.php"); + + $magicianObj = new imageLib($rp); + $magicianObj -> resizeImage($this->width_thumb, 300, 2); + $magicianObj -> saveImage($tp); + } self::$pictures[$directory . '/' . $fileInfos->getFilename()] = $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'legend', str_replace('.','',$fileInfos->getFilename())]); } } @@ -398,4 +458,4 @@ class galleriesHelper extends helper { } return $dirContent; } -} \ No newline at end of file +} diff --git a/module/gallery/view/gallery/gallery.php b/module/gallery/view/gallery/gallery.php index 6dde60ee..9a520bf9 100644 --- a/module/gallery/view/gallery/gallery.php +++ b/module/gallery/view/gallery/gallery.php @@ -13,12 +13,15 @@ $legend): ?>
- +
@@ -30,4 +33,4 @@
- \ No newline at end of file +