Skip to content

File link

media_directories_file_link adds a CKEditor 5 button that lets editors insert file download links<a> tags pointing at a Media entity's underlying file — without leaving the editor. Clicking the button opens the directories browser so the editor can pick the file.

Install

drush en media_directories_file_link

Dependencies: media_directories_browser, core ckeditor5, core media.

Configuration

The submodule has no admin page. There are two things to wire up after enabling it: a filter and a toolbar button.

Additional setup

1. Add the toolbar button

Open the text format that should support file download links — for example /admin/config/content/formats/manage/full_html — and drag Insert file link from Available buttons into the Active toolbar.

Active toolbar with the Insert file link button on the right

The Insert file link button is the rightmost icon in the active toolbar above (the page-with-an-arrow glyph). It opens the directories browser; the editor picks a file-based media item, and the module inserts a link to its underlying file at the cursor position.

The same format needs the Media file link filter enabled so the inserted <drupal-media-file-link> markup renders as a real <a> tag on the front-end. Tick it under Enabled filters on the format settings page. You can leave the filter at its default processing order — it transforms custom tags, not generic text.

Permissions

File link uses the existing permissions stack: the editor needs Access media directories browser (granted by media_directories_browser) plus the text format's Use permission. There's no file-link-specific permission to grant.

Verifying the install

  • Open a CKEditor 5 instance using the configured text format. The Insert file link button is present and opens the directories browser.
  • Picking a file-based media item inserts a link in the editor.
  • Previewing or rendering the content shows a working anchor that downloads the file.