Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When used in Drupal core 8.0.5 linkit doesn't link inline images properly.
In order to reproduce:
- Create basic page
- Upload an image through image CKEditor button
- Select image and click on linkit button
- Input URL
- See that the link is inserted before the image like for example '/node/25' and then image itself not linked.
This is the source markup that is generated:
<p><a href="node/25">node/25</a><img alt="Link Test" data-entity-type="file" data-entity-uuid="618c1ef3-1199-44ea-8300-f136503903bf" height="278" src="/sites/default/files/inline-images/Giant-Panda.jpg" width="418" /></p>
Comment | File | Size | Author |
---|---|---|---|
#3 | linkit_8_x_doesn_t_work-2691879-3.patch | 3.74 KB | star-szr |
Comments
Comment #2
amykhailova CreditAttribution: amykhailova commentedI have tested it on the 8.x-4.1 and 8.x-4.x-dev versions of the module, both had the same problem for me.
Comment #3
star-szrConfirmed, here's a patch which just pulls in code from the core Link plugin to handle images (makes the linkit CKEditor plugin more similar to the core link plugin).
This seems to work well and doesn't break normal linking as far as I can tell but needs more testing to confirm.
Note that you may need to clear browser cache to test this.
Comment #4
Wim LeersWow. All of this seemingly is only necessary because the LinkIt module reimplements all of the link dialog, instead of extending the existing one in Drupal 8.
Why doesn't this just alter EditorLinkDialog's form?
Comment #5
star-szrYeah I was kinda thinking to myself, why is this all repeated. Great point :)
Comment #6
anonExtend the default would be perfect, But I cant figure out how to extend the allowedContent part of the default. Any ideas?
Comment #7
Wim LeersLook at how the
drupalimagecaption
plugin extends thedrupalimage
plugin. It does exactly that IIRC :)Comment #8
anondrupalimage
anddrupalimagecaption
are using the widgetDefinition event.The
drupallink
plugin doesn't use that and I can't find any other way to alter the allowedContent.Any thoughts?
Comment #9
Wim LeersI wrote up my feedback in #2692831: Linkit 8.x-4.x flaws from the POV of the Text Editor/CKEditor APIs in Drupal 8 core.
For extending
allowedContent
for thedrupallink
CKEditor plugin (though I strongly doubt that is necessary here), you'd want to useafterInit
.Comment #10
anonFixed with #2692831.
Comment #12
omnimon CreditAttribution: omnimon commentedStill happening im afraid, with the latest release or dev release.
Comment #13
anon@omnimon: Na, I can not reproduce this. And it is very strange that this is still an issue for you as Linkit is now using the exact same js code as drupal core. Make sure to clear your cache.
Comment #14
thejimbirch CreditAttribution: thejimbirch commentedI just want to comment that upgrading to 8.x-5.x-dev fixed this for me.
Comment #15
heyehren CreditAttribution: heyehren as a volunteer commentedFor me the links are still added in front of the image, even with running the latest dev version 8.x-5.0-beta5+4-dev on Drupal 8.3.7 and clearing the cache.
UPDATE: Ok, it is working with img tags for me as well now. What still doesn't work is to link images added by the entity embed module. But this is an issue related to their module. I have fixed it for now by using https://www.drupal.org/project/entity_embed_link
Comment #16
Tritof CreditAttribution: Tritof commentedHi, I still have the problem Drupal 8.5.3 and linkit 8.4.3.
Comment #17
anonym-developer CreditAttribution: anonym-developer commentedConfirm #16, still the same issue with Drupal 8.5.6 and Linkit 8.4.3.
Comment #18
jasonflaherty CreditAttribution: jasonflaherty commentedConfirming the same issue as noted above. Internal, Files and External links all insert before image.
Comment #19
gobnat CreditAttribution: gobnat commentedThis is still happening for me.
Drupal version: 8.6.4
Any news if this is getting fixed?
Comment #20
alisonStill happening for me, too, core 8.7.6 + LinkIt 8.x-5.0-beta9 :(
Comment #21
embeau CreditAttribution: embeau at Aptitude Digital commentedI am still encountering this issue as well. Linkit version 8.x-4.3, Drupal version 8.6.7.
Comment #22
hkirsman CreditAttribution: hkirsman commentedI'm getting with this patch:
Adding the patch from here https://www.drupal.org/project/drupal/issues/2855521 makes the js error go away but
<a href="undefined">
I've now changed to 5.0-beta10 and it works (without the patches).
Comment #23
yojohnyo CreditAttribution: yojohnyo commentedI am encountering this problem on 8.x-5.0-beta10 Drupal version 8.8.4