summaryrefslogtreecommitdiff
path: root/modules/gallery/models
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/models')
-rw-r--r--modules/gallery/models/item.php6
1 files changed, 6 insertions, 0 deletions
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index 4a87a2ab..7fc37325 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -332,6 +332,12 @@ class Item_Model extends ORM_MPTT {
$tmp = pathinfo($this->name, PATHINFO_FILENAME);
$tmp = preg_replace("/[^A-Za-z0-9-_]+/", "-", $tmp);
$this->slug = trim($tmp, "-");
+
+ // If the filename is all invalid characters, then the slug may be empty here. Pick a
+ // random value.
+ if (empty($this->slug)) {
+ $this->slug = (string)rand(1000, 9999);
+ }
}
// Get the width, height and mime type from our data file for photos and movies.