Media file entities embedded through the wysiwyg do not use the weight of the file field. It defaults to null and is placed above all other fields in the display. Should just need to modify code introduced in http://drupal.org/node/1421786. But I can't seem to determine how to load a file entity that properly includes the file field's weight.

Comments

bburg’s picture

Follow up:

You could use file_view() directly in the media_token_to_markup() function to generate the renderable array instead of media_get_file_without_label(), but I'm not certain of the reason behind rendering the file, and the file entity's fields separately.

bburg’s picture

StatusFileSize
new1.93 KB

The amount of code this replaces makes me alarmed, but here's a potential patch for anyone interested in it.

bburg’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 1991912-wysiwyg-file-weight.patch, failed testing.

bburg’s picture

Status: Needs work » Needs review
StatusFileSize
new1.93 KB

Status: Needs review » Needs work

The last submitted patch, media-wysiwyg-file-weight-1991912-5.patch, failed testing.

bburg’s picture

Status: Needs work » Needs review
StatusFileSize
new1.14 KB
Tyler the Creator’s picture

Version: 7.x-2.0-unstable7 » 7.x-2.0-alpha3
Issue summary: View changes

I ran into this problem on 7.x-2.0-alpha3... The above patches don't really translate over though. I'll submit a patch if I figure out a clean solution. Any help would be greatly appreciated. Thanks!

Tyler the Creator’s picture

Fixed my problem on alpha3. Attached is the patch. Consequently this patch also fixed an error I had with image fields on the file not displaying and throwing an undefined error Notice: Undefined index: uri in theme_image_formatter() (line 602 of /.../modules/image/image.field.inc).

ParisLiakos’s picture

Version: 7.x-2.0-alpha3 » 7.x-2.x-dev
Status: Needs review » Needs work
  1. +++ b/includes/media.filter.inc
    @@ -378,6 +378,7 @@ function media_token_to_markup($match, $wysiwyg = FALSE) {
         $element['content']['file'] = media_get_file_without_label($file, $tag_info['view_mode'], $settings);
    

    Also file is already populated from file_view now..no need to run that

  2. +++ b/includes/media.filter.inc
    @@ -391,7 +392,6 @@ function media_token_to_markup($match, $wysiwyg = FALSE) {
         field_attach_prepare_view('file', array($file->fid => $file), $tag_info['view_mode']);
         entity_prepare_view('file', array($file->fid => $file));
    

    we should also get rid of those, since file_view() covers them

chris matthews’s picture

Status: Needs work » Closed (outdated)

Closing this issue as outdated. However, if you think this issue is still important, please let us know and we will gladly re-open it for review.
sincerely,
- the Drupal Media Team