Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Currently there is not option to use a media formatter on file fields. The only additional option is the "Large filetype icon".
Given that the media field is deprecated, it would be great if the formatter was available for the generic file formatter, so we could start to use this on the 7.x-1.x branch.
Comment | File | Size | Author |
---|---|---|---|
#16 | media-before-patch.png | 97.37 KB | chris_h |
#16 | media-after-patch.png | 105.53 KB | chris_h |
#8 | file_formatters-1390878-2.patch | 5.43 KB | gollyg |
#4 | file_formatters-1390878-2.patch | 1.14 KB | gollyg |
#1 | file_formatters-1390878-1.patch | 1.52 KB | gollyg |
Comments
Comment #1
gollyg CreditAttribution: gollyg commentedHere is a patch that seems to work, but would need some testing. The biggest issue with it is the need to load the file entities for a second time to retrieve the bundle information. This happens already in a media_field_prepare_view, but this function does not get called prior to rendering the file field. I imagine there is another way of processing this file list in a more elegant way, as this patch means it is happening in at least two places.
Comment #2
gollyg CreditAttribution: gollyg commentedI have tested with standard file fields on Drupal 7.10. All seems to work as expected.
Comment #4
gollyg CreditAttribution: gollyg commentedRe-rolled against dev
Comment #5
Dave ReidRather than re-using this formatter for the file type, I wonder if we should rather backport the 'Rendered file' formatter from File entity into Media 1.x's file_entity submodule - which would give us an added benefit of automatically supporting an upgrade path from 1.x to 2.x without any changes.
Comment #6
gollyg CreditAttribution: gollyg commentedYes, would make sense to keep it consistent with future versions. Will try to get onto a patch for that.
Comment #7
Dave ReidComment #8
gollyg CreditAttribution: gollyg commentedRecreated the patch, using the suggested formatter. I have kept the formatter in the file.fields.inc and added an include statement to the main module, to keep it as close as possible to the 2.x branch.
Comment #9
Dave ReidUpping priority and assigning for review.
Comment #10
wroxbox CreditAttribution: wroxbox commentedAfter applying the patch and clearing cache I get
Fatal error: Cannot redeclare file_entity_view_mode_labels() (previously declared in /sites/all/modules/file_entity/file_entity.module:364) in /sites/all/modules/file_entity/file_entity.module on line 719
It appears that file_entity_view_mode_labels() and file_entity_view_mode_label() functions are both declared twice in the same module.
Comment #11
wroxbox CreditAttribution: wroxbox commentedAfter removing douple declarations the functionality seems to works as defined. Works for me.
Comment #12
Dave Reid@wroxbox: If you are using the 7.x-1.x branch of Media, you should not have a sites/all/modules/file_entity module at all. You should have a sites/all/modules/media/file_entity since it's provided by Media and not a separate download.
Comment #13
wroxbox CreditAttribution: wroxbox commented@davereid: You are right. I installed file_entity first separately and then media.
I was trying to implement metadata to core file with file_entity without media.
Comment #14
Dave ReidAnyone please feel free to review.
Comment #15
discipolo CreditAttribution: discipolo commentedtested & reviewed the patch with the result:
the media formatter is now available
good work! pleasure joining the sprint.
Comment #16
chris_h CreditAttribution: chris_h commentedTested on a fresh install with media 1.x-dev and media_youtube 1.0-beta3. The patch successfully adds rendered file option file formatter option (see attached before/after), which correctly displays a video, preview etc depending on view mode.
Comment #17
cosmicdreams CreditAttribution: cosmicdreams commentedreviewed the patch and it looks solid. The only issue I found may be a non-issue: the .info file doesn't have a newline at the end. If that is irrevelent then this is RTBC
Comment #18
Taxoman CreditAttribution: Taxoman commentedRemoving tag, as 1.0 was released on March 23rd, regardless of this issue being tagged as a stable release blocker.
Comment #19
marvil07 CreditAttribution: marvil07 commentedI have just closed #1266786: 'media' formatter settings do not show up on display fields page and video is hidden on node detail page as duplicate in favor of this
Comment #20
Chaulky CreditAttribution: Chaulky commentedApplied and worked cleanly on 7.x-1.0 release
Comment #21
aaron CreditAttribution: aaron commented#8: file_formatters-1390878-2.patch queued for re-testing.
Comment #22
aaron CreditAttribution: aaron commentedadding a tag; it would be nice to get an rtbc on this issue
Comment #23
aaron CreditAttribution: aaron commentedwe need to make sure we add an update function to clear the cache, so that we catch the new formatter.
Comment #24
Steven Brown CreditAttribution: Steven Brown commentedPatch #8 worked like a charm. Thank you all for the help on this. It was greatly needed.
Comment #25
aaron CreditAttribution: aaron commentedgreat work everyone, it is committed now!
http://drupalcode.org/project/media.git/commit/7623c30 and http://drupalcode.org/project/media.git/commit/7c35747
Comment #27
rattusrattus CreditAttribution: rattusrattus commentedHi
I'm running the 7.x-1.1 version of the module but I am still unable to select the media format if I use a file field type and the Media file selector widget. I've enabled the module and set file display option under the file types menu, am I missing something?
Thanks ahead