Make link title editable / add token support / more options

Created on 6 June 2019, over 5 years ago
Updated 3 June 2024, 6 months ago

Follow-up issue from #2986967: Use Media name for the "Download Link" title β†’ where we discussed how to make the link title more flexible.
That issue was a bug report, this is a feature request to enhance functionality:

Wouldn't it perhaps be better to make the link formatter more flexible by adding options and perhaps work with media tokens instead of a hard coded solution? I don't think that there will be THAT ONE perfect link text.

Yes a selection sounds like a good option:

  • Media title
  • File name
  • Description
  • Perhaps a custom text option (translatable) would also make sense to have a custom link title. I think that's also needed in many cases.

Also we could add a checkbox to use the file description as title text for the link to provide flexibilty to use it as tooltip, etc... with minimal effort.

Let's discuss the demand for that here. In our case it would have helped a lot.

✨ Feature request
Status

RTBC

Version

2.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

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.

  • πŸ‡¬πŸ‡§United Kingdom robcarr Perthshire, Scotland

    The patch at 11 works fine.
    The patch at 15 is really helpful, but not necessarily relevant to this issue, and should be added to a fresh issue as a separate feature request.

  • πŸ‡§πŸ‡ͺBelgium bramvandenbulcke

    Patch #11 is working well. I'm using Drupal 10.2.5 at the moment.

    Steps taken:

    • Make sure download link is set for Document under /admin/structure/media/manage/document/display. And for my use case: add Name to the form display
    • Add patch #11 to composer.patches.json and run composer install
    • Copy the media-entity-download-link.html.twig template from /modules/contrib/media_entity_download/templates to the theme folder
    • Apply the changes in the markup. I'm using the Name field as the link text. This makes the most sense (the description field is not available anyway). This code inside the Twig block: {{ link|merge({'#title': media_entity.name.value }) }}
  • πŸ‡ΊπŸ‡ΈUnited States wrd-oaitsd

    Looks like this patch isn't applying to the latest dev release.

  • πŸ‡ΊπŸ‡ΈUnited States wrd-oaitsd

    Trying to reroll #11 for the latest dev release.

  • πŸ‡ΊπŸ‡ΈUnited States wrd-oaitsd

    That patch had a rather significant error...here's a new one.

Production build 0.71.5 2024