Skip to content

Commit 6939122

Browse files
authored
Fix for skip long HTML in short description
1 parent 8030608 commit 6939122

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Model/Post.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,8 @@ public function getShortFilteredContent($len = null, $endСharacters = null)
515515
/* Skip <style> tags at the begining of string in calculations */
516516
$sp1 = mb_strpos($content, '<style>');
517517
if (false !== $sp1) {
518-
$cc = preg_replace("~\<style(.*)\>(.*)\<\/style\>~", " ", $content); /* remove style tag */
518+
$stylePattern = "~\<style(.*)\>(.*)\<\/style\>~";
519+
$cc = preg_replace($stylePattern, '', $content); /* remove style tag */
519520
$sp2 = mb_strpos($content, '</style>');
520521

521522
while (false !== $sp1 && false !== $sp2 && $sp1 < $sp2 && $sp2 > $len && $sp1 < $len) {
@@ -536,16 +537,16 @@ public function getShortFilteredContent($len = null, $endСharacters = null)
536537
$cc = $content;
537538
}
538539

539-
/* Skip long Html */
540+
/* Skip long HTML */
540541
$stcc = trim(strip_tags($cc));
541-
if ($stcc && strlen($stcc) < strlen($cc) / 3) {
542+
//if ($stcc && strlen($stcc) < strlen($cc) / 3) {
542543
$str = '';
543544
$start = false;
544545
foreach (explode(' ', $stcc) as $s) {
545546
$str .= ($str ? ' ' : '') . $s;
546547

547548

548-
$pos = mb_strpos($content, $str, $len);
549+
$pos = mb_strpos($content, $str, $len);
549550
if (false !== $pos) {
550551
$start = $pos;
551552
} else {
@@ -558,10 +559,9 @@ public function getShortFilteredContent($len = null, $endСharacters = null)
558559
$len = $start + $oLen;
559560
}
560561
}
561-
}
562+
//}
562563
}
563564

564-
565565
/* Do not cut words */
566566
while ($len < strlen($content)
567567
&& !in_array($content[$len], [' ', '<', "\t", "\r", "\n"]) ) {

0 commit comments

Comments
 (0)