new option for image.prettyname_prefix

This commit is contained in:
Andy Miller
2019-03-13 18:04:52 -06:00
parent 2b16f813ef
commit a5e832b0b0
3 changed files with 18 additions and 2 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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;
}