In CKEditor 5, I use media in my nodes. I've got a big problem. When I click on the media while editing the node, it opens the file.
I want the media to be linked to the file only when the node is displayed, not in the form of the node.
In CKEditor 5 how not to link media to file, in node editing?
More use cases for linked media within CKeditor 5 are embedding documents, videos, and audio that are all interactive. I'm not sure the media module is the correct place to address whether media is clickable within the text editor. Right now the touch target for showing the contextual toolbar on a media item is a thin line around the image, document, video, etc. If you miss that line and click the media, you get one of two experiences:
Unlinked Media
If the media is an image without a configured linked display, you get the contextual media toolbar.

This is pretty much what an editor would expect.
Linked Media
If the media is a remote video, clicking on the media will play the video.

If the media is a document, clicking on the media will download the document.

| Comment | File | Size | Author |
|---|---|---|---|
| #19 | 3326455-19.patch | 1.72 KB | lauriii |
| #13 | click-on-document-media.png | 266.14 KB | joshuami |
| #13 | click-on-remote-video-media.png | 263.75 KB | joshuami |
| #13 | click-on-image-media.png | 257.62 KB | joshuami |
| Screenshot 2022-12-11 19.40.09.png | 463.55 KB | zenimagine |
Issue fork drupal-3326455
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
cilefen commentedhttps://drupal.stackexchange.com/questions/314021/in-ckeditor-5-how-not-...
Comment #3
zenimagine commentedThis behavior is weird and unintuitive. If the author presses the image without having made a backup, he loses his writing. In CKEditor this should be configurable. Same problem to display the parameters of the image, you have to click next to it and play with the arrows on the keyboard. If I click on the image to display the parameters, it displays the file. Do you find it logical and intuitive ?
Comment #4
zenimagine commentedComment #5
zenimagine commentedIt is necessary to add in the configuration of CKEditor 5 if the image must be linked to the file or not.
When I click on the image, I want to see the image configuration menu appear, not the file.
Comment #6
wim leersThanks for the detailed bug report, @zenimagine! 👏
Default
core/profiles/standard/config/optional/core.entity_view_display.media.image.default.ymlconfig:Note how
image_link: ''means that image media are not linked by default in this view mode. But you can change this toimage_link: contentorimage_link: file, in which case this will be linked.In that case, it's indeed possible to click the image media and the link will be followed.
Given this is non-standard configuration, I don't think this qualifies as , but it definitely is something that should be fixed.
Having read https://git.drupalcode.org/project/ckeditor/-/blob/1.0.x/js/plugins/drup..., I'm not sure CKEditor 4 protected against this either. We need to check that. If it worked correctly there, then this would be a regression.
@zenimagine: any chance you could check that? 😊🙏
Comment #7
zenimagine commentedDo you have a patch to disable photo links in CKEditor, when editing a node ?
Comment #8
wim leersNo, I haven't worked on a patch yet.
Comment #9
zenimagine commentedI have an image media type. I would like to display the image and the link to the file in the rendered Media. I don't want the image to be a link to the file.
I couldn't find a link to the file field in *Manage display*. I looked at the media.html.twig file, but I could not understand how to link to the file.
How can I add the media file link in *Manage display*?
Comment #10
wim leersThat is a question for the
media systemcomponent, not forckeditor5.module. I don't know the answer 😇I do acknowledge that the CKEditor 5 "media rendered with wrapping link" entity view display configuration is broken in CKEditor 5, that will be handled here 👍
Comment #11
joelpittetI was about to create this issue, glad it's here, ran into it when testing variations out #3348603: CKEditor 5 resizes images with % width instead of px width (the CKEditor 4 default): breaks image captions *and* is a regression Though not related to that issue I thought I'd reference it here for completeness.
Comment #12
lauriiiComment #13
joshuamiThe improvements to images embedded via CKeditor 5 are impressive, but all other media types suffer a little bit from an upgrade to CKeditor 5.
More use cases for linked media within CKeditor 5 are embedding documents, videos, and audio that are all interactive. I'm not sure the media module is the correct place to address whether media is clickable within the text editor. Right now the touch target for showing the contextual toolbar on a media item is a thin line around the image, document, video, etc. If you miss that line and click the media, you get one of two experiences:
Unlinked Media
If the media is an image without a configured linked display, you get the contextual media toolbar.
This is pretty much what an editor would expect.
Linked Media
If the media is a remote video, clicking on the media will play the video.
If the media is a document, clicking on the media will download the document.
For any media type other than image, the loss of an "edit media" button that has a decent touch target is a huge loss. The loss of an embed dialog that allows you to configure and possibly replace the media seems to also be the result of only looking at media management from an image perspective and not considering the embed complexities for other media types.
It would be a better experience, if a user could interact with a preview of the media entity where the entire embedded item is a trigger for the contextual toolbar. This would be similar to the link contextual toolbar which opens when you click the link rather than taking you to the link destination.
Updating the issue summary with the additional use cases.
Comment #14
el7cosmoswe should emulate demo in https://ckeditor.com/docs/ckeditor5/latest/features/media-embed.html#demo, clicking the media won't playing the video.
Comment #15
el7cosmosIt seems
pointer-events: nonecss rule do the tricksComment #17
el7cosmosComment #18
smustgrave commentedRan the test without the first to make sure it failed and got
1) Drupal\Tests\ckeditor5\FunctionalJavascript\MediaTest::testMediaPointerEvent
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'http://drupal-10.x.ddev.site/node/1/edit'
+'http://drupal-10.x.ddev.site/sites/simpletest/34354334/files/image-test.png'
/var/www/html/web/vendor/phpunit/phpunit/src/Framework/Constraint/Equality/IsEqual.php:96
/var/www/html/web/core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaTest.php:1687
/var/www/html/web/vendor/phpunit/phpunit/src/Framework/TestResult.php:728
Which is good so I'll remove that tag.
#6 was tagged for an issue summary update if that could happen next please.
Comment #19
lauriiiI think the issue summary is fine as of #13. At least I was able to figure out what this issue is about based on that.
Comment #20
joshuamiJust tested on a Drupal 10.1 site with the patch against a remote video and a document embed. In both cases, clicking the media item triggers the tooltip instead of triggering the interaction with the media item (playing the video or downloading the document).
Thanks for jumping in on this one @lauriii!
Comment #23
lauriiiCommitted d80291c and pushed to 11.x. Thanks! Also cherry-picked to 10.1.x since this is a bug fix.