Its just something I noticed, if the name of image is
123456789
and the code used would be
<?php echo truncate_string(getImageTitle(), 5);?>
the results will be
12345...
However if the name of the image is
123456789...
then the results would be
123456789...
I don't really see it as that much of a bug, but like I said I did notice this as a user of mine used ... in the name of a file and for some reason it did not truncate.
Not sure what you are seeing. The code is as follows:
` function truncate_string($string, $length, $elipsis='...') { if (strlen($string) > $length) { $pos = strpos($string, ' ', $length); if ($pos === FALSE) return substr($string, 0, $length) . $elipsis; return substr($string, 0, $pos) . $elipsis; } return $string; } ` This will find the last space prior to the designated length and truncate there or it will chop at the lenght, so I do not see how the example you show could have occurred.
Comments
`
<?php printTags(NULL, NULL, 'taglist', ""); ?>
`
`
<?php echo truncate_string(getImageTitle(), 19);?>
`
and the title includes ... in the name it does not truncate, funny bug I have to say.
123456789
and the code used would be
<?php echo truncate_string(getImageTitle(), 5);?>
the results will be
12345...
However if the name of the image is
123456789...
then the results would be
123456789...
I don't really see it as that much of a bug, but like I said I did notice this as a user of mine used ... in the name of a file and for some reason it did not truncate.
`
function truncate_string($string, $length, $elipsis='...') {
if (strlen($string) > $length) {
$pos = strpos($string, ' ', $length);
if ($pos === FALSE) return substr($string, 0, $length) . $elipsis;
return substr($string, 0, $pos) . $elipsis;
}
return $string;
}
`
This will find the last space prior to the designated length and truncate there or it will chop at the lenght, so I do not see how the example you show could have occurred.