By submitting patches for review, you agree to the Developer Certificate of Origin. A copy of this agreement can be found in the project root, named CONTRIBUTING.txt.
Problem/Motivation
It would be amazing if this module would support direct download, rather than just inline display of the media item!
Steps to reproduce
N/A
Proposed resolution
Emulate what Dropbox does, and check for dl=1 in the query string of the media item. If it's there, then set the Content-Disposition header to attachment to force a direct download.
Remaining tasks
Get maintainer's blessing
- Create a merge request with tests
- Review/manually test
- Commit it!
User interface changes
None.
API changes
None. I don't think this counts as API.
Data model changes
None.
Comments
Comment #2
phenaproximaMinor formatting change in the issue summary.
Comment #3
clayfreemanI'm in favor of this idea.
Comment #4
phenaproximaWelp, that was pretty simple!
Comment #6
clayfreemanThis looks pretty good! Pending CI results, my initial review is as follows:
We should update the cachable metadata to ensure that the response varies on context
url.query_args:dl.I think it'd also be wise to invalidate the
http_responsecache tag for thoroughness; otherwise a manual cache rebuild might be necessary fordl=1to take effect.Comment #7
phenaproximaGood idea on the cacheability metadata. I added the cache context, and corresponding test coverage, but I'm not sure what you mean by this:
In which cases should we invalidate the tag? Just if
dl=1, or in all situations?Comment #8
phenaproximaIn Slack, @clayfreeman clarified that the
http_responsecache tag should be cleared in an update hook, just to make things a little more seamless. So I've added a post-update function for that. No automated test coverage for it, since a) I wouldn't know how to test that and b) no data models are being changed.Comment #9
clayfreemanThis looks great to me! Thanks for your interest in the project :)
Comment #11
clayfreemanCR created & published here: https://www.drupal.org/node/3222821