Bug #103144
opencrop ViewHelper has a curious interpretation of respecting word boundaries
0%
Description
Hello,
the f:format.crop ViewHelper does not take the full string into account to cut at position of maxCharacters.
```
<f:format.crop maxCharacters="18" respectHtml="true" respectWordBoundaries="true"><p>Ein schönes Bild</p><img src="#" width="128" height="128" title="nice" alt="sonne"><p>Nicht wahr?</p></f:format.crop>
```
Results in:
```
<p>Ein schönes Bild</p><img src="#" width="128" height="128" title="nice" alt="sonne"/><p>Ni…</p>
```
The HtmlCropper cuts all text and html parts into sections. So, we have sections with p, sections with img and of cause two text sections in the resulting array. The expected behavior is, that the HtmlCropper should cut in front of "Nicht", but instead it cuts inside of that word. That's because internally this text is in another section and does not know anything about the previous text. That's why HtmlCropper thinks, that "Nichts" would be the first and only word and that why it cuts within the word instead of in front of that word.
German explanation with example: https://www.typo3lexikon.de/typo3-tutorials/core/systemextensions/fluid/viewhelper/format/#beispiel-nicht-im-html-trennen
Stefan
Updated by Georg Ringer 6 months ago
- Status changed from New to Accepted
confirmed but no clue how this could be really fixed or if there are any good html cropper out there. projects like https://github.com/judev/php-htmltruncator are also rather old
Updated by Gerrit Code Review 6 months ago
- Status changed from Accepted to Under Review
Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/84854
Updated by Gerrit Code Review 6 months ago
Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/84854
Updated by Gerrit Code Review 4 months ago
Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/84854
Updated by Gerrit Code Review about 2 months ago
Patch set 4 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/84854
Updated by Gerrit Code Review about 2 months ago
Patch set 5 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/84854