forked from ZwiiCMS-Team/ZwiiCMS
[10.0.054] conversion des miniatures
This commit is contained in:
parent
543c4911da
commit
96a8e2993f
@ -36,7 +36,7 @@ class common {
|
|||||||
const THUMBS_SEPARATOR = 'mini_';
|
const THUMBS_SEPARATOR = 'mini_';
|
||||||
|
|
||||||
// Numéro de version
|
// Numéro de version
|
||||||
const ZWII_VERSION = '10.0.053';
|
const ZWII_VERSION = '10.0.054';
|
||||||
const ZWII_UPDATE_CHANNEL = "v10";
|
const ZWII_UPDATE_CHANNEL = "v10";
|
||||||
|
|
||||||
public static $actions = [];
|
public static $actions = [];
|
||||||
@ -794,37 +794,36 @@ class common {
|
|||||||
|
|
||||||
function makeThumb($src, $dest, $desired_width) {
|
function makeThumb($src, $dest, $desired_width) {
|
||||||
|
|
||||||
$png = $jpg = false;
|
|
||||||
if (strpos($src,'jpg') > 0 ||
|
if (mime_content_type($src) === 'image/jpeg' ) {
|
||||||
strpos($src,'jpeg') > 0 ) {
|
if ($source_image = imagecreatefromjpeg($src)) {
|
||||||
$jpg = true;
|
|
||||||
}
|
|
||||||
if (strpos($src,'png') > 0 ) {
|
|
||||||
$png = true;
|
|
||||||
}
|
|
||||||
if ($png || $jpg ) {
|
|
||||||
/* read the source image */
|
|
||||||
$source_image = $jpg ? imagecreatefromjpeg($src) : imagecreatefrompng($src);
|
|
||||||
$width = imagesx($source_image);
|
$width = imagesx($source_image);
|
||||||
$height = imagesy($source_image);
|
$height = imagesy($source_image);
|
||||||
|
|
||||||
/* find the "desired height" of this thumbnail, relative to the desired width */
|
/* find the "desired height" of this thumbnail, relative to the desired width */
|
||||||
$desired_height = floor($height * ($desired_width / $width));
|
$desired_height = floor($height * ($desired_width / $width));
|
||||||
|
|
||||||
/* create a new, "virtual" image */
|
/* create a new, "virtual" image */
|
||||||
$virtual_image = imagecreatetruecolor($desired_width, $desired_height);
|
$virtual_image = imagecreatetruecolor($desired_width, $desired_height);
|
||||||
|
|
||||||
/* copy source image at a resized size */
|
/* copy source image at a resized size */
|
||||||
imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $width, $height);
|
imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $width, $height);
|
||||||
|
|
||||||
/* create the physical thumbnail image to its destination */
|
/* create the physical thumbnail image to its destination */
|
||||||
if ($png) {
|
|
||||||
imagepng($virtual_image, $dest);
|
|
||||||
}
|
|
||||||
if ($jpg) {
|
|
||||||
imagejpeg($virtual_image, $dest);
|
imagejpeg($virtual_image, $dest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( mime_content_type($src) === 'image/png' ) {
|
||||||
|
/* read the source image */
|
||||||
|
if ($source_image = imagecreatefrompng($src)) {;
|
||||||
|
$width = imagesx($source_image);
|
||||||
|
$height = imagesy($source_image);
|
||||||
|
/* find the "desired height" of this thumbnail, relative to the desired width */
|
||||||
|
$desired_height = floor($height * ($desired_width / $width));
|
||||||
|
/* create a new, "virtual" image */
|
||||||
|
$virtual_image = imagecreatetruecolor($desired_width, $desired_height);
|
||||||
|
/* copy source image at a resized size */
|
||||||
|
imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $width, $height);
|
||||||
|
/* create the physical thumbnail image to its destination */
|
||||||
|
imagepng($virtual_image, $dest);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1196,8 +1195,12 @@ class common {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//----------------------------------------
|
||||||
// Mise à jour de la taille des miniatures
|
// Mise à jour de la taille des miniatures
|
||||||
$iterator = new DirectoryIterator($this->getdata(['module',$parent,$galleryKey,'config','directory']));
|
$iterator = new DirectoryIterator('site/file/source');
|
||||||
foreach($iterator as $fileInfos) {
|
foreach($iterator as $fileInfos) {
|
||||||
if($fileInfos->isDot() === false AND $fileInfos->isFile() AND @getimagesize($fileInfos->getPathname())) {
|
if($fileInfos->isDot() === false AND $fileInfos->isFile() AND @getimagesize($fileInfos->getPathname())) {
|
||||||
if (!file_exists( str_replace('source','thumb',$fileInfos->getPathname()) . '/' . self::THUMBS_SEPARATOR . strtolower($fileInfos->getFilename()))) {
|
if (!file_exists( str_replace('source','thumb',$fileInfos->getPathname()) . '/' . self::THUMBS_SEPARATOR . strtolower($fileInfos->getFilename()))) {
|
||||||
@ -1207,12 +1210,6 @@ class common {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Mettre à jour les données des galeries
|
|
||||||
//----------------------------------------
|
|
||||||
|
|
||||||
$this->setData(['core', 'dataVersion', 10000]);
|
$this->setData(['core', 'dataVersion', 10000]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user