mirror of
https://github.com/danpros/htmly.git
synced 2026-04-23 05:56:22 +05:30
Improve teaser
This commit is contained in:
parent
f0431bb35e
commit
2107ef20a0
1 changed files with 8 additions and 0 deletions
|
|
@ -933,6 +933,9 @@ function get_description($string, $char = null)
|
|||
{
|
||||
if(empty($char)) {
|
||||
$char = config('description.char');
|
||||
if(empty($char)) {
|
||||
$char = 150;
|
||||
}
|
||||
}
|
||||
$string = remove_accent($string);
|
||||
$string = preg_replace('/[^A-Za-z0-9 !@#$%^&*(),.-]/u', ' ', strip_tags($string));
|
||||
|
|
@ -948,10 +951,15 @@ function get_teaser($text, $char = null)
|
|||
|
||||
if(empty($char)) {
|
||||
$char = config('teaser.char');
|
||||
if(empty($char)) {
|
||||
$char = 200;
|
||||
}
|
||||
}
|
||||
|
||||
if ($teaserType === 'full') {
|
||||
echo $text;
|
||||
} elseif (strlen(strip_tags($text)) < $char) {
|
||||
echo preg_replace('/\s\s+/', ' ', strip_tags($text));
|
||||
} else {
|
||||
$string = preg_replace('/\s\s+/', ' ', strip_tags($text));
|
||||
$string = substr($string, 0, $char);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue