Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't truncate HTML if content length is less than summary size #1125

Merged
merged 3 commits into from
Oct 25, 2016
Merged

Don't truncate HTML if content length is less than summary size #1125

merged 3 commits into from
Oct 25, 2016

Conversation

xadammr
Copy link
Contributor

@xadammr xadammr commented Oct 21, 2016

Fixes #1114 by comparing size of $content against the summary size. If a $content is short and doesn't require a summary to be generated, return it's original form.

Copy link
Member

@rhukster rhukster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You know, it probably makes more sense to put this check at the top of the Utils::truncateHTML() method, then it will be more reliably wherever truncate is used.

@xadammr
Copy link
Contributor Author

xadammr commented Oct 23, 2016

Hi @rhukster, good call. I couldn't see anywhere else in the codebase where TruncateHtml was called, but placing the sanity check in the Utils:truncateHtml makes sense going forward. I have updated my pull request.

@flaviocopes flaviocopes merged commit cd15b91 into getgrav:develop Oct 25, 2016
@xadammr xadammr deleted the patch-1 branch October 25, 2016 23:23
dliessi added a commit to dliessi/grav that referenced this pull request May 2, 2018
The original fix provided by getgrav#1125 in Utils::truncateHTML compared the
summary size with the full HTML string length.
Thus, the string was still being truncated (and the HTML rewritten) even
when only the HTML string length, and not the text length, exceeded the
summary size.
dliessi added a commit to dliessi/grav that referenced this pull request May 4, 2018
The original fix provided by getgrav#1125 in Utils::truncateHtml compared the
summary size with the full HTML string length.
Thus, the string was still being truncated (and the HTML rewritten) even
when only the HTML string length, and not the text length, exceeded the
summary size.
rhukster pushed a commit that referenced this pull request May 15, 2018
* Move fix for #1114 to Truncator::truncateLetters

The original fix provided by #1125 in Utils::truncateHtml compared the
summary size with the full HTML string length.
Thus, the string was still being truncated (and the HTML rewritten) even
when only the HTML string length, and not the text length, exceeded the
summary size.

* Add fix for #1114 also to Truncator::truncateWords
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants