diff options
-rw-r--r-- | phpfspot.class.php | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/phpfspot.class.php b/phpfspot.class.php index 723140f..a511648 100644 --- a/phpfspot.class.php +++ b/phpfspot.class.php @@ -226,16 +226,30 @@ class PHPFSPOT { public function getPhotoName($idx, $limit = 0) { if($details = $this->get_photo_details($idx)) { - $name = $details['name']; - if($limit != 0 && strlen($name) > $limit) { - $name = substr($name, 0, $limit-5) ."...". substr($name, -($limit-5)); - } + $name = $this->shrink_text($details['name'], $limit); return $name; } } // getPhotoName() /** + * shrink text according provided limit + * + * If the length of the name exceeds $limit the + * text will be shortend and some content in between + * will be replaced with "..." + */ + private function shrink_text($text, $limit) + { + if($limit != 0 && strlen($text) > $limit) { + $text = substr($text, 0, $limit-5) ."...". substr($text, -($limit-5)); + } + + return $text; + + } // shrink_text(); + + /** * translate f-spoth photo path * * as the full-qualified path recorded in the f-spot database |