- π¦πΊAustralia timfletcher
True @Steve - Drupal picks up the
data-entity-substitution
attribute and processes it when the page is saved and the filters are processed.If the value is '
canonical
', it points to the Media entity. If you replace it with 'media
', it points to to the file.You could do a bulk Find and Replace (carefully) to save the pain of finding and replacing all your media links.
- πΊπΈUnited States mark_fullmer Tucson
Worth noting that you need to set this up first before adding your links as media items. Content added prior will not update automatically
I wrote up β¨ Previously created media URLs should update if the matcher is changed from canonical to direct URL Active to raise the question of whether media entity URLs should be updated retroactively. I'm not sure it *should*, but we can think about it!
- πΊπ¦Ukraine ruslan piskarov Kyiv, Ukraine
Is this issue again in 6.1.4 and 7.0.0-alpha1 or did I miss something?
With "Direct URL to media file entity" option I see an URL like media/XXX. - πΊπΈUnited States mark_fullmer Tucson
Is this issue again in 6.1.4 and 7.0.0-alpha1 or did I miss something?
With "Direct URL to media file entity" option I see an URL like media/XXX.I just functionally tested both 6.1.4 and the latest commit on the 7.x branch, and in both cases, the resulting rendered link to the media entity does go, as expected, to the media file (e.g., sites/default/files). To be clear, the source code in CKEditor will show
media/XXX
as in the following example, but when rendered, it does provide the link to the filesystem.<a href="/media/1" data-entity-type="media" data-entity-uuid="263229c1-f780-4d65-a09e-9c401342caa6" data-entity-substitution="media">test</a>
If
data-entity-substitution="canonical"
, it will render/media/XXX
, but ifdata-entity-substitution="media"
it will render the direct link.Documentation about this is at https://www.drupal.org/docs/extending-drupal/contributed-modules/contrib... β
@ruslan, let me know if that doesn't answer your question correctly.
- πΊπ¦Ukraine ruslan piskarov Kyiv, Ukraine
Thank you, @mark_fullmer, for your reply.
I am looking again.A fresh D10 site enabled the Linkit module v 7.0.0-alpha1 and media macher.
Create two media 1.jpg and 2.png.
In CKeditor
Create a node with "Text Link" text and two images (one image inserted as media, one uploaded as file).
Link all elements to "2.png" media.A source code will be
<p> <a href="/media/4" data-entity-type="media" data-entity-uuid="2142ef3f-60e0-4115-80ce-8d460aa5406a" data-entity-substitution="media">Text Link</a> </p> <a href="/media/4"><drupal-media data-entity-type="media" data-entity-uuid="c390e8a9-0b66-4c44-8bd3-dd79b95d4c65"> </drupal-media></a> <a href="/media/4"><img src="/sites/default/files/inline-images/3.jpg" data-entity-uuid="3d311f2c-0dad-4ef6-a1ec-949d0c069523" data-entity-type="file" width="1800" height="943"></a>
Rendered HTML will be
<p> <a href="/sites/default/files/2024-11/2.pdf" data-entity-type="media" data-entity-uuid="2142ef3f-60e0-4115-80ce-8d460aa5406a" data-entity-substitution="media" title="2.pdf">Text Link</a> </p> <a href="/media/4"> <div class="media media--type-image media--view-mode-default"> <div class="field field--name-field-media-image field--type-image field--label-visually_hidden"> <div class="field__label visually-hidden">Image</div> <div class="field__item"> <img loading="lazy" src="/sites/default/files/styles/large/public/2024-11/1.jpg.webp?itok=5BbDYn1H" width="480" height="251" alt="test"> </div> </div> </div> </a> <a href="/media/4"> <img data-entity-uuid="3d311f2c-0dad-4ef6-a1ec-949d0c069523" data-entity-type="file" src="/sites/default/files/inline-images/3.jpg" width="1800" height="943" loading="lazy"> </a>
So, it works nicely with texts but has media issues.
- πΊπΈUnited States mark_fullmer Tucson
Thanks for the further testing, @ruslan_piskarov. I think you're pointing out a specific issue with links wrapping media, which is described in the Linkit issue at π¬ Links surrounding Media Library item strips data-entity-type and data-entity-uuid Postponed , and has been traced back to core issue β¨ Drastically improve the linking experience in CKEditor 5 Needs work . If that sounds right to you, then I think this issue -- the direct media option -- is still "works as designed" and can remain closed without further work.
- πΊπ¦Ukraine ruslan piskarov Kyiv, Ukraine
@mark_fullmer, you are right. I didn't see #3317769 before. Thank you very much for the quick response, and have a tremendous day.