Add a core feature to rename new image and thumbnail with his MD5 hash
This commit is contained in:
parent
17ddd0343d
commit
cd242e8d3f
6 changed files with 25 additions and 4 deletions
|
@ -443,6 +443,15 @@
|
||||||
<!-- Images tab -->
|
<!-- Images tab -->
|
||||||
<div class="tab-pane fade" id="images" role="tabpanel" aria-labelledby="images-tab">
|
<div class="tab-pane fade" id="images" role="tabpanel" aria-labelledby="images-tab">
|
||||||
<?php
|
<?php
|
||||||
|
echo Bootstrap::formCheckbox(array(
|
||||||
|
'name'=>'renameImageWithHash',
|
||||||
|
'label'=>'',
|
||||||
|
'labelForCheckbox'=>$L->g('rename-new-images-and-thumbnails-with-hash'),
|
||||||
|
'checked'=>$site->renameImageWithHash(),
|
||||||
|
'placeholder'=>'',
|
||||||
|
'tip'=>$L->g('Activate').' / '.$L->g('Deactivate')
|
||||||
|
));
|
||||||
|
|
||||||
echo Bootstrap::formTitle(array('title'=>$L->g('Thumbnails')));
|
echo Bootstrap::formTitle(array('title'=>$L->g('Thumbnails')));
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
echo Bootstrap::formInputText(array(
|
||||||
|
|
|
@ -879,7 +879,7 @@ function transformImage($file, $imageDir, $thumbnailDir=false) {
|
||||||
|
|
||||||
// Generate a filename to not overwrite current image if exists
|
// Generate a filename to not overwrite current image if exists
|
||||||
$filename = Filesystem::filename($file);
|
$filename = Filesystem::filename($file);
|
||||||
$nextFilename = Filesystem::nextFilename($imageDir, $filename);
|
$nextFilename = Filesystem::nextFilename($imageDir, $filename, $site->renameImageWithHash());
|
||||||
|
|
||||||
// Move the image to a proper place and rename
|
// Move the image to a proper place and rename
|
||||||
$image = $imageDir.$nextFilename;
|
$image = $imageDir.$nextFilename;
|
||||||
|
|
|
@ -217,7 +217,7 @@ class Filesystem {
|
||||||
|
|
|
|
||||||
| @return string
|
| @return string
|
||||||
*/
|
*/
|
||||||
public static function nextFilename($path=PATH_UPLOADS, $filename) {
|
public static function nextFilename($path=PATH_UPLOADS, $filename, $hash=false) {
|
||||||
// Clean filename and get extension
|
// Clean filename and get extension
|
||||||
$fileExtension = pathinfo($filename, PATHINFO_EXTENSION);
|
$fileExtension = pathinfo($filename, PATHINFO_EXTENSION);
|
||||||
$fileExtension = Text::lowercase($fileExtension);
|
$fileExtension = Text::lowercase($fileExtension);
|
||||||
|
@ -225,6 +225,10 @@ class Filesystem {
|
||||||
$filename = Text::removeSpaces($filename);
|
$filename = Text::removeSpaces($filename);
|
||||||
$filename = Text::removeQuotes($filename);
|
$filename = Text::removeQuotes($filename);
|
||||||
|
|
||||||
|
if ($hash) {
|
||||||
|
$filename = md5($filename);
|
||||||
|
}
|
||||||
|
|
||||||
// Search for the next filename
|
// Search for the next filename
|
||||||
$tmpName = $filename.'.'.$fileExtension;
|
$tmpName = $filename.'.'.$fileExtension;
|
||||||
if (Sanitize::pathFile($path.$tmpName)) {
|
if (Sanitize::pathFile($path.$tmpName)) {
|
||||||
|
|
|
@ -43,6 +43,7 @@ class Site extends dbJSON {
|
||||||
'titleFormatTag'=> '{{tag-name}} | {{site-title}}',
|
'titleFormatTag'=> '{{tag-name}} | {{site-title}}',
|
||||||
'imageRestrict'=> true,
|
'imageRestrict'=> true,
|
||||||
'imageRelativeToAbsolute'=> false,
|
'imageRelativeToAbsolute'=> false,
|
||||||
|
'renameImageWithHash' => false,
|
||||||
'thumbnailWidth'=> 400, // px
|
'thumbnailWidth'=> 400, // px
|
||||||
'thumbnailHeight'=> 400, // px
|
'thumbnailHeight'=> 400, // px
|
||||||
'thumbnailQuality'=> 100,
|
'thumbnailQuality'=> 100,
|
||||||
|
@ -119,6 +120,11 @@ class Site extends dbJSON {
|
||||||
return DOMAIN_BASE.'sitemap.xml';
|
return DOMAIN_BASE.'sitemap.xml';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function renameImageWithHash()
|
||||||
|
{
|
||||||
|
return $this->getField('renameImageWithHash');
|
||||||
|
}
|
||||||
|
|
||||||
public function thumbnailWidth()
|
public function thumbnailWidth()
|
||||||
{
|
{
|
||||||
return $this->getField('thumbnailWidth');
|
return $this->getField('thumbnailWidth');
|
||||||
|
|
|
@ -376,6 +376,7 @@
|
||||||
"thumbnail-width-in-pixels": "Thumbnail width in pixels (px).",
|
"thumbnail-width-in-pixels": "Thumbnail width in pixels (px).",
|
||||||
"thumbnail-height-in-pixels": "Thumbnail height in pixels (px).",
|
"thumbnail-height-in-pixels": "Thumbnail height in pixels (px).",
|
||||||
"thumbnail-quality-in-percentage": "Thumbnail quality in percentage (%).",
|
"thumbnail-quality-in-percentage": "Thumbnail quality in percentage (%).",
|
||||||
|
"rename-new-images-and-thumbnails-with-hash": "Rename new images and thumbnails with hash",
|
||||||
"maximum-load-file-size-allowed:": "Maximum load file size allowed:",
|
"maximum-load-file-size-allowed:": "Maximum load file size allowed:",
|
||||||
"file-type-is-not-supported": "File type is not supported. Allowed types:",
|
"file-type-is-not-supported": "File type is not supported. Allowed types:",
|
||||||
"page-content": "Page content",
|
"page-content": "Page content",
|
||||||
|
|
|
@ -376,6 +376,7 @@
|
||||||
"thumbnail-width-in-pixels": "Largeur de la miniature en pixels (px).",
|
"thumbnail-width-in-pixels": "Largeur de la miniature en pixels (px).",
|
||||||
"thumbnail-height-in-pixels": "Hauteur de la miniature en pixels (px).",
|
"thumbnail-height-in-pixels": "Hauteur de la miniature en pixels (px).",
|
||||||
"thumbnail-quality-in-percentage": "Qualité des miniatures en pourcentage (%).",
|
"thumbnail-quality-in-percentage": "Qualité des miniatures en pourcentage (%).",
|
||||||
|
"rename-new-images-and-thumbnails-with-hash": "Renommer les nouvelles images et miniatures avec un hash",
|
||||||
"maximum-load-file-size-allowed:": "Taille maximale des fichiers autorisée :",
|
"maximum-load-file-size-allowed:": "Taille maximale des fichiers autorisée :",
|
||||||
"file-type-is-not-supported": "Le type de fichier n’est pas supporté. Liste des extensions autorisées :",
|
"file-type-is-not-supported": "Le type de fichier n’est pas supporté. Liste des extensions autorisées :",
|
||||||
"page-content": "Contenu de la page",
|
"page-content": "Contenu de la page",
|
||||||
|
|
Loading…
Add table
Reference in a new issue