#95818rte_ckeditor link around image generates faulty frontend html
Description
Version 10.4.21
How to reproduce:
- include fluid styled content
- enable images for editor (if you use Default.yaml, use removePlugins: null
- create text element
- enter image
- link to an external url
- save and check frontend
Example html in editor:
<p><a href="https://www.google.de/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png"><img alt="" data-htmlarea-file-uid="5" src="https://yourdomain.com/fileadmin/_processed_/2/8/csm_e6a44eba77_2b4acbbd70.png" style="height:101px; width:300px" /></a></p>
@

Reviews 1
History 511
-
Marco H commented and changed subject
rte_ckeditor external link around image causes two paragraphs in frontend, one with link, one with imagerte_ckeditor link around image generates faulty frontend html description 11/05/21, 07:21 -
Riccardo De Contardi commented 11/07/21, 10:32
What would be the result if you use https://extensions.typo3.org/extension/rte_ckeditor_image ?
-
Marco H commented 11/07/21, 15:31
Riccardo De Contardi wrote in #note-2:
> What would be the result if you use https://extensions.typo3.org/extension/rte_ckeditor_image ?Same issue in frontend.
I was actually noticing the problem on a website that uses rte_ckeditor_image, was about to report it there but did a last check without the extension – same behaviour. What rte_ckeditor_image does fix though is the editor generation of the image after adding a link. -
Lars Tode commented 05/12/22, 11:04
The issue with the link is located in file
RteLinkBrowser. Currently the methodgetSelectedText()used to get the content for the link.If the content is an image the method return nothing since it is an element and not a text.
A simple solution could be checking if the selection is an element and the text is empty.
Example:
if (selection && selection.getSelectedElement() !== null) { linkElement.append(selection.getSelectedElement()); } else if (selection && selection.getSelectedText()) { linkElement.setText(selection.getSelectedText()); } else { linkElement.setText(linkElement.getAttribute('href')); } -
Gerrit Code Review pushed patch set 1 for main to change 74640 status
NewUnder Review 05/13/22, 05:48 -
Gerrit Code Review pushed patch set 2 for main to change 74640 05/13/22, 08:28
-
Gerrit Code Review pushed patch set 3 for main to change 74640 05/16/22, 08:08
-
Gerrit Code Review pushed patch set 4 for main to change 74640 06/02/22, 10:56
-
Gerrit Code Review pushed patch set 5 for main to change 74640 05/03/23, 09:31
-
Gerrit Code Review pushed patch set 6 for main to change 74640 10/18/24, 14:06
-
Benni Mack commented and changed status
Under ReviewClosed 04/12/25, 19:52Sorry, I will close this issue now… This fix is for CKeditor4 and both our code (rte-link-browser.ts) and CKEditor5 (image handling + plugin API) have changed since TYPO3 v12.
I cannot reproduce this AT ALL anymore.
If you still have issues, let me know – let’s then open up a new issue for CKEditor5 then.
Edit:
Similar problem with link to page or file, so it seems to be a general issue with images.
Also , if the link is set via the editor button, the image-html is replaced by the href-value, so
<p><img alt="" data-htmlarea-file-uid="5" src="https://yourdomain.com/fileadmin/_processed_/2/8/csm_e6a44eba77_2b4acbbd70.png" style="height:101px; width:300px" /></p>+ adding a link turns into
<p><a href="t3://page?uid=1">t3://page?uid=1</a></p>