Turning off Force Download setting on media entity field has no effect

Created on 15 May 2023, over 1 year ago

Problem/Motivation

I have :Force Download: turned off on my display for the file field on the Document media entity type.





However I am still getting the "download" attribute printed in the HTML output.


Steps to reproduce

I am referencing a PDF file in a media entity (bundle = document) from a Paragraph entity. That paragraph is in turn being referenced from a node.

If I go to line 269 of the FileDownloadLinkMedia.php and replace this codeblock:

if ($this->getSetting('force_download')) {
   $options['attributes']['download'] = TRUE;
}

with:

$options['attributes']['download'] = FALSE;

then I get the expected result. I guess the the `force_download` config isn't being stored correctly and is always evaluating to TRUE (the default value).

🐛 Bug report
Status

Closed: cannot reproduce

Version

2.0

Component

Code

Created by

🇦🇺Australia jaydee1818 Melbourne

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @jaydee1818
  • 🇦🇺Australia jaydee1818 Melbourne
  • 🇦🇺Australia jaydee1818 Melbourne
  • 🇦🇺Australia jaydee1818 Melbourne
  • 🇮🇳India shailja179 India

    @jaydee1818
    This is working fine with Drupal9.5. It can be some caching issue. You can try clearing cache.
    It is working fine for me.

  • Status changed to Needs review over 1 year ago
  • Status changed to Closed: cannot reproduce over 1 year ago
  • 🇺🇸United States danflanagan8 St. Louis, US

    Hi @jaydee1818,

    Thanks for the issue! Unfortunately (or perhaps fortunately depending on how you look at it) I could not reproduce this bug. I was using the file_download_link_media field formatter and tried with various configurations with and without token enabled. The presence of the `download` attribute always matched the configuration I had set. This covered by an automated test case in Drupal\Tests\file_download_link\Kernel\FileDownloadLinkMediaTest as well.

    I'm going to close as Cannot Reproduce, but if you can provide clear test steps to reproduce the issue, please re-open and I will investigate.

    Cheers!

Production build 0.71.5 2024