diff --git a/bl-kernel/admin/views/settings.php b/bl-kernel/admin/views/settings.php
index b0ff9031..88d2e0d6 100644
--- a/bl-kernel/admin/views/settings.php
+++ b/bl-kernel/admin/views/settings.php
@@ -443,6 +443,15 @@
'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::formInputText(array(
diff --git a/bl-kernel/functions.php b/bl-kernel/functions.php
index fde68de2..d6d474ea 100644
--- a/bl-kernel/functions.php
+++ b/bl-kernel/functions.php
@@ -879,7 +879,7 @@ function transformImage($file, $imageDir, $thumbnailDir=false) {
// Generate a filename to not overwrite current image if exists
$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
$image = $imageDir.$nextFilename;
diff --git a/bl-kernel/helpers/filesystem.class.php b/bl-kernel/helpers/filesystem.class.php
index 1ff4a6eb..d9ff65b7 100644
--- a/bl-kernel/helpers/filesystem.class.php
+++ b/bl-kernel/helpers/filesystem.class.php
@@ -217,7 +217,7 @@ class Filesystem {
|
| @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
$fileExtension = pathinfo($filename, PATHINFO_EXTENSION);
$fileExtension = Text::lowercase($fileExtension);
@@ -225,6 +225,10 @@ class Filesystem {
$filename = Text::removeSpaces($filename);
$filename = Text::removeQuotes($filename);
+ if ($hash) {
+ $filename = md5($filename);
+ }
+
// Search for the next filename
$tmpName = $filename.'.'.$fileExtension;
if (Sanitize::pathFile($path.$tmpName)) {
diff --git a/bl-kernel/site.class.php b/bl-kernel/site.class.php
index 11285f82..5383edcd 100644
--- a/bl-kernel/site.class.php
+++ b/bl-kernel/site.class.php
@@ -43,6 +43,7 @@ class Site extends dbJSON {
'titleFormatTag'=> '{{tag-name}} | {{site-title}}',
'imageRestrict'=> true,
'imageRelativeToAbsolute'=> false,
+ 'renameImageWithHash' => false,
'thumbnailWidth'=> 400, // px
'thumbnailHeight'=> 400, // px
'thumbnailQuality'=> 100,
@@ -119,6 +120,11 @@ class Site extends dbJSON {
return DOMAIN_BASE.'sitemap.xml';
}
+ public function renameImageWithHash()
+ {
+ return $this->getField('renameImageWithHash');
+ }
+
public function thumbnailWidth()
{
return $this->getField('thumbnailWidth');
@@ -420,4 +426,4 @@ class Site extends dbJSON {
return json_decode($customFields, true);
}
-}
\ No newline at end of file
+}
diff --git a/bl-languages/en.json b/bl-languages/en.json
index b9a34543..7327ef0a 100644
--- a/bl-languages/en.json
+++ b/bl-languages/en.json
@@ -376,6 +376,7 @@
"thumbnail-width-in-pixels": "Thumbnail width in pixels (px).",
"thumbnail-height-in-pixels": "Thumbnail height in pixels (px).",
"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:",
"file-type-is-not-supported": "File type is not supported. Allowed types:",
"page-content": "Page content",
diff --git a/bl-languages/fr_FR.json b/bl-languages/fr_FR.json
index eebb4a47..61a2947b 100644
--- a/bl-languages/fr_FR.json
+++ b/bl-languages/fr_FR.json
@@ -376,6 +376,7 @@
"thumbnail-width-in-pixels": "Largeur 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 (%).",
+ "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 :",
"file-type-is-not-supported": "Le type de fichier n’est pas supporté. Liste des extensions autorisées :",
"page-content": "Contenu de la page",
@@ -392,4 +393,4 @@
"define-custom-fields-for-the-content": "Define custom fields for the content. Learn more about custom fields in the
documentation<\/a>.",
"start-typing-to-see-a-list-of-suggestions": "Start typing to see a list of suggestions.",
"view": "View"
-}
\ No newline at end of file
+}