This is easy using a PHP function. Look at this example:
function trim_text($input, $length) {
// If the text is already shorter than the max length, then just return unedited text.
if (strlen($input) <= $length) {
return $input;
}
// Find the last space (between words we're assuming) after the max length.
$last_space = strrpos(substr($input, 0, $length), ' ');
// Trim
$trimmed_text = substr($input, 0, $last_space);
// Add ellipsis.
$trimmed_text .= '...';
return $trimmed_text;
}
You can then pass in text with a function like:
trim_text('My super long title', 10);
(I haven't tested this, but it should work perfectly.)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…