Download Link Labeler Drupal Module

Screenshot of Drupal Download Link Labeler Project

Websites that need to meet Section 508 Accessibility Rules and other government agency accessibility guidelines are tasked with the requirement to label links to downloadable content with the file type and file size of the referenced media, like PDFs. This creates the task of maintaining countless links entered into the body content of pages across the entire website. This task is nearly impossible to perform manually, considering that these links may reference external content on other websites not controlled by the content manager. So, when a PDF file is updated at the same URL the file size needs to be recalculated or else the download link label is no longer meeting regulations. Will all of these other website's have the courtesy of notifying the content manager when the file size changes for a PDF that they host?

Visit the Download Link Labeler Project Page on

I wrote a Drupal Module that installs a text filter and uses native Drupal HTTP methods to automatically do this work, consistently the same way, for all links entered into the CKEditor text editor. The Download Link Labeler module is available for both Drupal 7 and 8. The advantage for my server-side PHP solution over a JavaScript based solution, is that web browser's Cross Site Scripting limitations prevent calculating the file size of remotely hosted content in the client user's web browser. Drupal's built in plugins can easily calculate remote file size by using Guzzle to only retrieve the content-length header of the remotely hosted media file. This shortcut ensures that the entirety of the remote content doesn't need to be downloaded in order to calculate file size. In effect, remotely hosted media can be calculated nearly as fast as the internal, locally-hosted media files. The module after some simple configuration, will automatically label file type and file size of all of the links embedded in the text editor powered body content quickly when cache is generated.

Review the Download Link Labeler Code Repository on GitLab