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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

malcomio created an issue. See original summary.

malcomio’s picture

Seems 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:

'#value' => isset($item['display']) ? $item['display'] : $field['settings']['display_default'],

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

malcomio’s picture

Status: Active » Needs review
FileSize
981 bytes
malcomio’s picture

Looks 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).

malcomio’s picture

Reading those related issues more closely, looks like we need to check if the array index exists first - here's an alternative patch.

RedEight’s picture

Would 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.

yfma’s picture

Thanks for the patch , it solves the issue !

dutchyoda’s picture

Updated this issue for 2.0-beta14

brockfanning’s picture

I'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.

joseph.olstad’s picture

Status: Needs review » Fixed

committed to 7.x-2.x dev

Status: Fixed » Closed (fixed)

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