DrupalCon Baltimore: 161 sessions, many voices, infinite possibilities. Earlybird rate ends Friday.
The media-field is defined as having 3 properties:
data. The default widget is only capable of setting the
fid property, which is a reasonable trade-off, as most only needs this.
However, I just created a new widget where I'm able to set title and a description (saved in
data) as well as
fid. I then went about theming the output so I could write out these two extra properties. This however, proved to be impossible! Here's the reason:
media_field_prepare_view throws away the information!
The hook is given the field-data in the
&$items variable, which is looped through to find
fids, and then replaced with the loaded media entries! Formatter hooks are thus unable to act upon anything but the media entities referenced by the fields.
I've created a very simple patch that adds the
field-property to each loaded media-instance with the original information of the corresponding
$item. This way the information is retained and can be accessed by formatters and possibly from the theme. (Perhaps the property should be called something else?
The patch is very simple, and there's probably a more clever way of achieving the same. But it does the job.
What's the opinion on this? Shouldn't this information be retained? Otherwise, why does the two extra properties exist on the media field?
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch media_field_title_reroll.patch. Unable to apply patch. See the log in the details link for more information. View
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch media_field_data.patch. View
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch media-field-information_0.patch. View
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch media-field-information.patch. View