Forums

List category posts
Suggestion: Improving string cut when building excerpts (2 posts)

  1. Andrey Kiselev
    Member
    Posted 6 months ago #

    Hello, Fernando!
    Thanks for the grat plugin!
    Just one suggestion to improve it a little bit. When you build excerps you cut strings exactly at 252-nd char. This results in showing "black-diamond-question-mark" sometimes when cutting cyrillic strings. In order to work this out, you can cut string at a nearest space.

    So, this is your original string (CatList.php):

    $lcp_excerpt = substr($lcp_excerpt, 0, 252) . '...';

    And my suggestion is to replace it with this one:

    $lcp_excerpt = substr( $lcp_excerpt, 0, strrpos( substr( $lcp_excerpt, 0, 252 ), ' ' ) ) . '...';

    So, it just cuts excerpt at the nearest space before 252nd char.

    Cheers,
    Andrey

  2. Andrey Kiselev
    Member
    Posted 4 months ago #

    The bug is still here. I just want to share a link illusttating how does it look like:

    Screenshot

    Could you please include the fix in the next release?

Reply

You must log in to post.

About this Plugin

About this Topic