Skip to content

Commit 7c426d7

Browse files
committed
Short content end characters fix
1 parent 342680b commit 7c426d7

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Model/ShortContentExtractor.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,21 @@ public function execute($content, $len = null, $endCharacters = null)
157157
}
158158

159159
if ($endCharacters === null) {
160-
$endCharacters = '';
160+
$endCharacters = $this->scopeConfig->getValue(
161+
'mfblog/post_list/end_characters',
162+
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
163+
);
161164
}
162165

163166
if ($len && $endCharacters) {
164167
$trimMask = " \t\n\r\0\x0B,.!?";
165168
if ($p = strrpos($content, '</')) {
169+
$p2 = $p;
170+
do {
171+
$p = $p2;
172+
$p2 = strrpos($content, '</', $p - strlen($content) - 1);
173+
} while ($p2 && $p - $p2 <= 6);
174+
166175
$content = trim(substr($content, 0, $p), $trimMask)
167176
. $endCharacters
168177
. substr($content, $p);

0 commit comments

Comments
 (0)