Project

General

Profile

Actions

Bug #103144

open

crop ViewHelper has a curious interpretation of respecting word boundaries

Added by Stefan Froemken 10 months ago. Updated about 2 months ago.

Status:
Under Review
Priority:
Should have
Assignee:
-
Category:
Fluid
Target version:
Start date:
2024-02-17
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
13
PHP Version:
8.3
Tags:
Complexity:
Is Regression:
Sprint Focus:

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

Actions #1

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

Actions #2

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

Actions #3

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

Actions #4

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

Actions #5

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

Actions #6

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

Actions

Also available in: Atom PDF