Closed (fixed)
Project:
File Download
Version:
8.x-1.0-beta3
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
20 Jan 2017 at 12:54 UTC
Updated:
15 Jul 2017 at 00:18 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
idebr commentedAttached passes the correct description to
template_preprocess_download_file_link(), so the description correctly overrides the file name.Comment #3
oliveyrc commentedApplies cleanly and works for me.
Comment #4
oliveyrc commentedComment #5
NewZeal commentedPatch added and committed in 8.x-1.x-dev. Please check and confirm that it works as expected.
Comment #6
oliveyrc commentedI've tried using the latest dev version but it now has broken the display of the files.
Upon looking it appears that the $elements array is getting nuked when passing the field attributes to the theme function, around here
But it does appear that this patch has been applied okay and I can see the change in the source.
Rich
Comment #7
idebr commentedThere are currently three problems with the file description on HEAD:
template_preprocess_download_file_link(). Instead the title is hardcoded totemplate_preprocess_download_file_link()function because the 'description' was removed from its theme function infile_download_theme()@New Zeal: can you explain if the description should be able to override the file name? If so, for what field formatter option?
Comment #8
NewZeal commentedMy apologies, the cat has been fiddling with my code :)
$elements[$delta] = array('#attributes' =>array());Pushed to 8.x-1.x.
Comment #9
idebr commentedThe description now overwrites the filename (or any other title selected in the file download file formatter options) on 8.x-1.x.
Comment #10
NewZeal commentedOk, I've had another look at the patch that you supplied and I see it is overwriting the $title for which we have options selected. Therefore I have reversed the original patch.
There is some confusion in that the template_preprocess_download_file_link() function refers to description when it should be title (which I have now changed). I'm not sure where $item->description comes from or we would want to use in our output.
The description is still being passed, so it is still available in the template. Here is the output from the formatter:
So the patch is not actually being reversed.
Comment #11
oliveyrc commentedHave tested latest version 8.x-1.0-beta3 and it works as expected.
Cheers
Comment #12
oliveyrc commentedFixing version string
Comment #13
idebr commentedIt appears this behavior was changed (again) in 8.x-1.x. In HEAD the description is not used.
The description is added by the File module when the option 'Enable Description field' is selected in the Field settings. This option is explained as 'The description field allows users to enter a description about the uploaded file.'. Then in the content edit form, the description mentions: 'The description may be used as the label of the link to the file'.
The file module uses the description as the link text when a user enters it, see
template_preprocess_file_link()at file.module:1263Users entering a description may expect the description to be displayed as the link title, but this is currently not the case. Perhaps the option 'Title of file' should be reworded to 'Use the default file naming behavior' and let the description override the filename as the file.module does?
Comment #14
NewZeal commentedOK, I see now. How about we add the description as one of the options for the link title? See patch.
I should note that the patch you originally supplied overwrote our title options in favour of the file description. The options allow the link title to be altered separately for each instance where the formatter is used, such as in Views. That is not the case with the file description.
Comment #15
idebr commentedYes, that will work. Keep in mind the description may be empty, since it is an optional field. I suppose the link text will default to the filename in
template_preprocess_download_file_link(), which matches the behavior for the file.moduleComment #16
NewZeal commentedWe should test just that. We are currently using:
if (empty($variables['title']))I'm not sure if that returns empty if string is empty.
Comment #17
NewZeal commentedAs far as I know this issue is now fixed.
Comment #18
NewZeal commented