Fix generating snippet text if the teaser text is shorter than the minimal length

This commit is contained in:
kolaente 2021-05-26 15:33:52 +02:00
parent 81b16772d7
commit 27f66b40bd
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 2 additions and 0 deletions

View File

@ -43,6 +43,8 @@ class TextSnippet extends Modifier
$value = $text;
}
$lengthMin = strlen($value) < $lengthMin ? strlen($value) : $lengthMin;
$firstSentenceEnd = strpos($value, '.', $lengthMin);
if ($firstSentenceEnd <= $lengthMax) {
return substr($value, 0, $firstSentenceEnd + 1);