From bedc39342514a37d311274210f30a4abd14284fa Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 21 Mar 2017 20:11:48 -0700 Subject: begin the process of using the relevant attach directory/path for photo albums instead of an album basename which may not be unique. Created an 'ellipsify()' function to shorten long names and keep the beginning and end intact --- include/text.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index 500c87ad5..49b588f13 100644 --- a/include/text.php +++ b/include/text.php @@ -3113,3 +3113,14 @@ function array_escape_tags(&$v,$k) { $v = escape_tags($v); } +function ellipsify($s,$maxlen) { + if($maxlen & 1) + $maxlen --; + if($maxlen < 4) + $maxlen = 4; + + if(mb_strlen($s) < $maxlen) + return $s; + + return mb_substr($s,0,$maxlen / 2) . '...' . mb_substr($s,mb_strlen($s) - ($maxlen / 2)); +} \ No newline at end of file -- cgit v1.2.3