Introduction

Handle links to managed files in formatted textareas through some hook_form_alter() magic, a permanent filelink hook_menu() and a format filter.

Permanent Filelink is a solution to the problem of stale inline file links in user
content, especially in formatted (possibly wysiwyg) textareas such as on
entity create/edit forms and block configuration forms, where the user can
pick images or documents through a built-in file browser, e.g. imce, elfinder, ckfinder
and such.

When saving an entity create/edit form or a block configuration form, the form
submit handler will scan the submitted text, and replace any occurrence of
links to managed files with a generic link based on the Drupal file id (fid).

This generic link is served by a corresponding menu hook, so the files will always be visible/clickable.

When viewing the entity or the block, the Permanent Filelink filter will translate
these permafilelinks back into the canonical form. Additionally, this filter provides some rudimentary post-processing for more specialized link output.

Now, the user can insert filelinks independently of filepath, i.e. the file can be moved around without breaking the link.

Installation

Install as you would normally install a contributed Drupal module. See:
https://drupal.org/documentation/install/modules-themes/modules-7
for further information.

Configuration

Configure filters

To configure text formats, go to "Administration » Configuration » Content authoring » Text formats".

Visit the desired text formats and enable the "Permanent File Link" filter. This would usually be text formats that has a wyswyg editor enabled, but any text format will work.

With the filter enabled, an option tab becomes available. Click "Enable further link shortening" if additional link substitution is required. This is useful when special webserver rewrite rules for file links is active.

General configuration

For general configuration go to "Administration » Configuration » Media » Permanent Filelink".

For extended reporting during content editing, click "Enable verbose reporting".
With this setting various issues encountered during file link filtering will be reported with Drupal messages.

Similar Projects

Pathologic will try to repair stale/broken links in all sorts of ways, but it takes no special action regarding managed files. Permanent Filelink will prevent links to managed files from breaking in the first place.

Portable Path does much the same as Permanent Filelink, but instead of showing an active, live link, it substitutes file links with a plain token. The user cannot see the file (e.g. an image), while editing in wysiwyg mode.

Project information

Releases