Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I use file entity together with media_youtube module and it seems that download formatter does not work well when I a user try to download a youtube video. Actually there is nothing to download and I think that correct behavior of the formatter will be to skip all the external files.
Comment | File | Size | Author |
---|---|---|---|
#5 | download_formatter-2152323-4.patch | 797 bytes | xcf33 |
#2 | download_formatter-2152323-2.patch | 631 bytes | Devin Carlson |
#1 | download_formatter-2152323-1.patch | 626 bytes | boyan.borisov |
Comments
Comment #1
boyan.borisov CreditAttribution: boyan.borisov commentedI've made a patch which will skip all the files with filesize == 0 from the download formatter.
Comment #2
Devin Carlson CreditAttribution: Devin Carlson commentedThanks for the patch!
We should be able to use the
file_entity_file_is_local()
function to determine if the file is local.Comment #3
Devin Carlson CreditAttribution: Devin Carlson commentedTested and confirmed that #2 restricted the download formatter to local files which resulted in it no longer being chosen to render remote files that can't be downloaded. I also checked to make sure that it would still be available to modules like Remote Stream Wrapper.
Committed #2 to File Entity 7.x-2.x.
Comment #4
xcf33 CreditAttribution: xcf33 commentedHi
I ran into similar issue with this but more so with the download link views handler,
I think a different approach to this would be to not only restrict (file_entity_file_is_local($file)) because there are many use cases where local file directory is not used (Amazon S3, Rackspace cloud files, etc)
I have attached 2 patches, one illustrate by using a simple hook we can allow modules to declare probably either schemes not allowed (youtube, vimeo, etc).
Comment #5
xcf33 CreditAttribution: xcf33 commentedComment #6
xcf33 CreditAttribution: xcf33 commentedComment #8
pianomansam CreditAttribution: pianomansam commentedWhile the applied patch fixes the download link for external files, I'm not sure it does it the best way. I've discovered at least one bug that is caused by this patch - #2276437: External files using download formatter lose custom link text. Please see that issue with a different proposed patch that still fixes this issue but doesn't cause adverse side effects.