From 27f66b40bd46cd7d25ce463e00a2655f56f4e466 Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 26 May 2021 15:33:52 +0200 Subject: [PATCH] Fix generating snippet text if the teaser text is shorter than the minimal length --- src/Modifiers/TextSnippet.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Modifiers/TextSnippet.php b/src/Modifiers/TextSnippet.php index d4c8ae8..9040932 100644 --- a/src/Modifiers/TextSnippet.php +++ b/src/Modifiers/TextSnippet.php @@ -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);