function _asset_wizard_truncate in Asset 6
Same name and namespace in other branches
- 5.2 asset_wizard.module \_asset_wizard_truncate()
1 call to _asset_wizard_truncate()
File
- ./
asset_wizard.module, line 574 - Wizard-style interface for Asset.
Code
function _asset_wizard_truncate($text, $max_chars) {
if (strlen($text) > $max_chars) {
$text = substr($text, 0, $max_chars);
$last_word = strrchr($text, ' ');
if ($last_word == ' ') {
$text = substr($text, 0, strlen($text) - 1) . '...';
}
else {
$text = preg_replace('/' . preg_quote($last_word, '/') . '$/', '...', $text);
}
}
return $text;
}