diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-09-08 20:03:55 -0700 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-09-08 20:03:55 -0700 |
commit | 48becbe017758fb6fb95f0806ece879764249f37 (patch) | |
tree | 60a599bdb68c7bc23d97125ff5b665e8b8cd79ce /modules/gallery/helpers | |
parent | 453fb76443898746b72a0a2ddd419cf8e54f4207 (diff) |
Update item::convert_filename_to_slug() to eliminate leading and
trailing hyphens.
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r-- | modules/gallery/helpers/item.php | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php index d907a177..e015cb72 100644 --- a/modules/gallery/helpers/item.php +++ b/modules/gallery/helpers/item.php @@ -113,7 +113,11 @@ class item_Core { * @param string $filename */ static function convert_filename_to_slug($filename) { - return preg_replace("/[^A-Za-z0-9-_]+/", "-", pathinfo($filename, PATHINFO_FILENAME)); + $result = pathinfo($filename, PATHINFO_FILENAME); + $result = preg_replace("/[^A-Za-z0-9-_]+/", "-", $result); + $result = preg_replace("/^-+/", "", $result); + $result = preg_replace("/-+$/", "", $result); + return $result; } /** |