diff --git a/system/blueprints/config/system.yaml b/system/blueprints/config/system.yaml index 73785d62d..e83d86e45 100644 --- a/system/blueprints/config/system.yaml +++ b/system/blueprints/config/system.yaml @@ -1062,6 +1062,17 @@ form: validate: type: bool + images.prettyname_prefix: + type: toggle + label: PLUGIN_ADMIN.IMAGES_PRETTYNAME_PREFIX + help: PLUGIN_ADMIN.IMAGES_PRETTYNAME_PREFIX_HELP + highlight: 1 + options: + 1: PLUGIN_ADMIN.YES + 0: PLUGIN_ADMIN.NO + validate: + type: bool + media.enable_media_timestamp: type: toggle label: PLUGIN_ADMIN.ENABLE_MEDIA_TIMESTAMP diff --git a/system/config/system.yaml b/system/config/system.yaml index 0656fc3d0..403b69252 100644 --- a/system/config/system.yaml +++ b/system/config/system.yaml @@ -133,6 +133,7 @@ images: cache_perms: '0755' # MUST BE IN QUOTES!! Default cache folder perms. Usually '0755' or '0775' debug: false # Show an overlay over images indicating the pixel depth of the image when working with retina for example auto_fix_orientation: false # Automatically fix the image orientation based on the Exif data + prettyname_prefix: true # The hash prefix, set to false to not include hash prefix media: enable_media_timestamp: false # Enable media timestamps diff --git a/system/src/Grav/Common/Page/Medium/ImageMedium.php b/system/src/Grav/Common/Page/Medium/ImageMedium.php index 9369e3658..15d705136 100644 --- a/system/src/Grav/Common/Page/Medium/ImageMedium.php +++ b/system/src/Grav/Common/Page/Medium/ImageMedium.php @@ -240,7 +240,8 @@ class ImageMedium extends Medium { $this->set('prettyname', $name); if ($this->image) { - $this->image->setPrettyName($name); + $prefix = Grav::instance()['config']->get('system.images.prettyname_prefix', true); + $this->image->setPrettyName($name, $prefix); } } @@ -583,10 +584,13 @@ class ImageMedium extends Medium // Make sure we free previous image. unset($this->image); + // Get prefix + $prefix = Grav::instance()['config']->get('system.images.prettyname_prefix', true); + $this->image = ImageFile::open($file) ->setCacheDir($cacheDir) ->setActualCacheDir($cacheDir) - ->setPrettyName($this->getImagePrettyName()); + ->setPrettyName($this->getImagePrettyName(), $prefix); return $this; }