Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
When using the media browser, the file display field does not affect whether the file is actually displayed.
Steps to reproduce
1. Add a File field to a content type, using the "Media browser" widget, and enable the Display field
2. Create a node with a file in that field, and uncheck "Include file in display"
Expected result
The file is not displayed (to admins or anonymous users)
Actual result
The file is displayed.
If using the "File" widget, the file display works as expected.
Comment | File | Size | Author |
---|---|---|---|
#8 | include_file_in-2593377-8.patch | 603 bytes | dutchyoda |
| |||
#5 | include_file_in-2593377-5.patch | 604 bytes | malcomio |
Comments
Comment #2
malcomio CreditAttribution: malcomio commentedSeems like the field has a value set to 1, no matter what the current value is.
In media.fields.inc, inside media_field_widget_process, the element value is being set:
Tried changing that to #default_value, but it had no effect - the form input still had a value of 1 inside node_form_submit in node.pages.inc
Comment #3
malcomio CreditAttribution: malcomio commentedComment #4
malcomio CreditAttribution: malcomio commentedLooks like it works even without the addition of the value_callback from the previous patch.
As far as I can see, this bug would have been introduced in the fix for #2492241: Media as part of a field collection causes notice: http://cgit.drupalcode.org/media/commit/?id=dea5d0a
Also related is #1430934: Notice: Undefined index: display_field in file_field_widget_value() (line 582 of /module/file/file.field.inc).
Comment #5
malcomio CreditAttribution: malcomio commentedReading those related issues more closely, looks like we need to check if the array index exists first - here's an alternative patch.
Comment #6
RedEight CreditAttribution: RedEight at 95Visual commentedWould this issue have anything to do with "Allowed file types" not being taken into account? I have two File Types set up to handle images and I've got only one of them selected in allowed file types. Regardless, they both show up as an option when uploading files via the Media Browser widget.
Comment #7
yfma CreditAttribution: yfma commentedThanks for the patch , it solves the issue !
Comment #8
dutchyodaUpdated this issue for 2.0-beta14
Comment #9
brockfanning CreditAttribution: brockfanning commentedI've tackled this area in another issue: #2821745: "Display" checkboxes in media field widget always assume "Files displayed by default" is on
Does that issue have any connection, and/or is that patch useful? My memory is that it's a thorny issue because it's hard to distinguish an empty value from and intentionally unchecked checkbox.
Comment #11
joseph.olstadcommitted to 7.x-2.x dev