Filter for file_path – proposal
-
Hello DLM Team,
thank you for a great tool! I have a proposal for a new feature (filter), which is a one-line code modification.
I am looking for a way to watermark the downloaded files. The watermark is dynamic (contains the user’s name and the download time), so the watermarking should happen inside of DLM_Download_Handler->trigger(). There is an action hook “dlm_downloading” that sits at just the right location to watermark the file, but because it is a hook and not a filter, it does not allow me to substitute the watermarked file for the file specified in $file_path.
The workaround that I implemented is inserting a filter for $file_path, which is called inside trigger() right after the call to parse_file_path. The filter looks like this:
$file_path = apply_filters('dlm_file_path', $file_path)
Using this filter, I call my routine that watermarks the file and returns the temporary $file_path, which points to the watermarked file. Later, in download_headers, I have to change $headers[‘Content-Length’] for the download to work correctly. But, thankfully, you already have the filter “dlm_download_headers” for this.
Bottom line, I have the watermarking functionality working, but it required modifying the DLM code. Perhaps you will find this modification valuable and incorporate it in the code? This could open an opportunity for extension development for download customization, such as watermarking.
Cheers!
- The topic ‘Filter for file_path – proposal’ is closed to new replies.