While trying out module Entity Embed, I ran into a problem that whenever I chose to have the embedded image display as "Rendered File", nothing would show #2634350: "Rendered File" plugin doesn't work. I eventually traced the problem to file_entity_field_formatter_view(), where the file was being put into a recursion queue that didn't actually do anything!

I searched to see why that code was there and found #1447186: Rendered File formatter doesn't respect Field Display settings in Media Browser and #2061625: The 'Rendered file' formatter should not be available as a checkbox on the 'Manage file display' tab that indicate that the whole recursion queue scheme was abandoned 2 years ago, but the code was never taken out!

I propose that it be taken out now so that embedded files can be rendered.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

aDarkling created an issue. See original summary.

aDarkling’s picture

Devin Carlson’s picture

Status: Active » Needs review
Devin Carlson’s picture

Status: Needs review » Fixed

Tested #2 and committed with some additional code cleanup.

derekw’s picture

I just updated from the february dev to april 21 dev and my images are now not displaying.

Line 286 of file_entity_field.inc now has:

foreach ($items as $delta => $item) {
        if (!empty($item['file'])) {
          $files[$item['fid']] = $item['file'];
        }
      }

If I dsm($Item) it has $item['fid'] but not $item['file']. The $item appears to be the file. So the test if ($empty($item['file'])) is failing...and no images are being displayed.

Dave Reid’s picture

I think there's also a problem with the follow-up committed with http://cgit.drupalcode.org/file_entity/commit/?id=f74eb9a - we need to make sure that we're returning the field formatter output indexed by the correct $delta values.

Dave Reid’s picture

Status: Fixed » Needs review
FileSize
1.12 KB

Based on file_field_load() and what all of our other formatters do, we should be converting $item to an object to render it. I also wanted to simplify and unify this with the entity reference field formatter.

Dave Reid’s picture

Updated correct call to file_view().

Dave Reid’s picture

Also, I'm *pretty sure* we're going to break something outside of this module with this removal of this code:

        $files_display[$fid]->referencing_entity = $entity;
        $files_display[$fid]->referencing_entity_type = $entity_type;
        $files_display[$fid]->referencing_field = $field['field_name'];

That code came with #2333107: Allow file formatter to known the type of the referencing entity.

Dave Reid’s picture

This re-adds the references. I tried to go back through all the code that touched this formatter to make sure we are accounting for regressions. #1784762: File description lost when using Rendered file formatter and Generic file display is accounted for since $item['description'] will get converted to $file->description now.

Dave Reid’s picture

Got rid of the exception and just logging it instead now, more like D8.

Dave Reid’s picture

Title: file_entity_field_formatter_view() not working for File entity types » file_entity_field_formatter_view() not working with Entity Embed
Dave Reid’s picture

Using more D8 style of counting recursion, but left out $instance['bundle'] because it seems like Entity Embed in D7 doesn't have $instance['bundle'].

mattlt’s picture

Hello,

The commit related to this issue…

http://cgit.drupalcode.org/file_entity/commit/?id=e17e4b82793b4e8c5ea6e9...

And possibly related to the cleanup after…

http://cgit.drupalcode.org/file_entity/commit/?id=f74eb9a856c4443366e332...

…caused our sites not to be able to render files referenced by both views and panels.

Reverting the cleanup commit seemed to get the files back, but then I had the errors. Reverting both got everything working back to normal. We are not using the Entity Embed module so I'm not sure how that relates.

Not sure where to go from here other than letting you know the above changes broke our installs.

Please let me know if you have any questions.

Thanks,

•• matt

  • Dave Reid committed 621a20c on 7.x-2.x
    Issue #2640106 by Dave Reid: Fixed regressions in...
Dave Reid’s picture

Status: Needs review » Fixed

Committed #14 to 7.x-2.x.

Status: Fixed » Closed (fixed)

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