• Resolved meestorx

    (@meestorx)


    What line in downloadHandler.php do I need to edit to change the default download link from “attachment” to “inline”? I want pdfs to open on the webpage. Changed it before the latest update and worked great. Not sure what line to fix now…

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hello @meestorx ,

    You can use this filter so manipulate the headers so that you don’t have to modify the plugin file ( not recommended to modify it as it will be overridden on every plugin update ).

    Hope this helps!

    Warmly,
    Razvan

    Thread Starter meestorx

    (@meestorx)

    Thank you for your fast reply. That sounds great, but could you be able to give me directions on how to use that to change “attachment” to “inline” in the header exactly?

    Sure, you can do something like:

    add_filter('dlm_download_headers',function ( $headers ) {
    
    $headers['Content-Disposition'] = 'inline;';
    
    return $headers;
    }, 15, 1 );
    Thread Starter meestorx

    (@meestorx)

    Ty. Added that, but it’s not quite fixing the issue. It’s better, but not quite there. With that filter added, if I click the link (a pdf file), it still downloads the file, BUT, if I right-click and select “open in new tab” it opens the pdf inline within the new tab. (And before you ask, I do have “open safe files” enabled in Safari) Tested on:
    MacOS Ventura 13.2.1/Safari 16.3
    MacOS Big Sur 11.7.4/Safari 16.3.1
    Windows 10 22H2/Edge 110.0.1587.57

    Opens properly in FF, but likely FF handles things differently internally, as it does that regardless of whether the filter is in place or not.

    • This reply was modified 2 years ago by meestorx.

    Could you please let me know what plugin version you were using prior to this update? Also, could you let me know how did you put the download links inside pages? Were them from shortcodes or direct links by copying the download link?

    Warmly,
    Razvan

    Thread Starter meestorx

    (@meestorx)

    That’s a good question. I hadn’t verified download operation for quite some time, but likely it changed sometime in 2022. my notes indicate the line in DownloadHandler.php that needed to be edited was originally line 639 (changing “attachment” to “inline”) if that helps?

    I use shortcodes, e.g. [download id=”1234″] on the web page.

    Clicking the link from the webpage (e.g. a manual from here: https://mindplacesupport.com/kasina/#manuals) makes the pdf download. If I copy/paste the link that download monitor gives, however, it works correctly (appearing inline). (e.g. https://mindplacesupport.com/download/1244/?tmstv=1677770853)

    Thank you for your help!

    • This reply was modified 2 years ago by meestorx.

    I understand. We’ve moved from PHP forced file downloads to XHR file downloads, and possibly that is the reason why currently there is a difference between clicking and paste & go links behavior when content-disposition is set to inline.

    Regarding the Firefox, yes, it has a rule set that opens PDF files directly in the browser ( setting that can be changed ).

    Currently we are investigating the possibility to open the file in the browser directly using XHR, but for the launched version currently can’t be done.

    You can disable XHR ( in the future this won’t be possible as we’re going on that direction ) by entering the following snippet into your child theme’s functions.php file, but the accuracy of the Reports will suffer a little.

    add_filter( <span class="pl-s">'dlm_do_xhr'</span>, <span class="pl-s">'__return_false'</span> );

    Hope this helps.

    Warmly,
    Razvan

    Thread Starter meestorx

    (@meestorx)

    Thank you. It would be great if this can be remedied in a future version. In what way will reports be affected?
    BTW, on a mobile browser using Safari, it opens the attachments inline as expected.

    The reports won’t be so accurate regarding download status, download location and such.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘inline attachment’ is closed to new replies.