Direct Link to File in Media Entity Document

Created on 27 November 2017, almost 7 years ago
Updated 16 August 2024, about 1 month ago

Hi

I have created a Document Media Entity Bundle using media_entity_document Version: 8.x-1.1.

The bundle has a single File field in it

I would like the ability to link directly to the file instead of the media entity.

I found this https://www.drupal.org/node/2866525 β†’ commit and have setup my Linkit profile and html filters as documented.

Problem is, when I create a link, it still links to the media entity URL (e.g. /media/6) instead of the direct URL of the file in contains.

Am I missing something?

Thanks
Daniel

πŸ’¬ Support request
Status

Fixed

Version

7.0

Component

Code

Created by

πŸ‡¦πŸ‡ΊAustralia danjordan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¦πŸ‡Ί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 Kiev, 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 if data-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.

Production build 0.71.5 2024