Problem/Motivation

It would be nice if one could also provide a filename to the download attribute. As per HTML spec the download attribute could be used either with or without a filename value. Currently it is only possible to set the download attribute without filename.

Steps to reproduce

Proposed resolution

Provide an additional setting for providing a filename to the download attribute (using tokens too), dependent on the force download attribute.

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

stefan.korn created an issue. See original summary.

stefan.korn’s picture

Assigned: stefan.korn » Unassigned
Status: Active » Needs review

Regarding tests I am not too proficient. I would maybe need some input on this. I guess I fixed on of the failing tests, but probably one would have the tests not only fixed, but also targeting the new setting.

Kindly ask for review.

danflanagan8’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Hi, @stefan.korn. The MR looks really good. I really like the use of #states on the settings form. I would be happy to update the tests to cover this new feature.

Out of curiosity, would you describe the use case where setting force_download_filename was a requirement?

stefan.korn’s picture

Hi @danflanagan8, yes #states is really nice, but I always forget the syntax and need to regoogle it ;-)

We use file download for a image gallery, where we provide an option for users to download the image in full size. We use an image media for the images and editors can give a name different from the filename to the image media and we want to have the downloaded image named like the image media is named (if this differs from real filename). That works fine on almost any browser as far as I can tell and if it would not work for some browser it would take the real filename, which is also nice because it does not break the functionality.

danflanagan8’s picture

Assigned: Unassigned » danflanagan8

Thanks for the clear reply, @stefan.korn. That scenario makes a lot of sense and seems like really good UX for the end user.

I'll assign this issue to myself to get some tests written.

danflanagan8’s picture

Assigned: danflanagan8 » Unassigned

I totally forgot about this one. I got let go from my previous employer like two days after my most recent comment. My contrib time has been really thin since then. I still think this is a good idea. I'm going to unassign this from myself though since I probably won't be writing the tests any time soon.

astonvictor made their first commit to this issue’s fork.

astonvictor’s picture

Status: Needs work » Fixed

Added the option to add the filename.
updated the MR by fixing tests and updated another plugin for media entities.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.