Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quasi’s picture

Still no luck with this issue.

burgs’s picture

This is an issue with all filefields inside field collections.

quasi’s picture

Is there a solution to this problem?

Thank you!

mgriebe’s picture

I concur that this is an active issue. I have a field_slideshow and a field collection with a single image. These are the warnings I get when I preview a field collection with a slideshow:

    Notice: Undefined index: uri in field_slideshow_field_formatter_view() (line 581 of /var/www/hmcc/sites/all/modules/field_slideshow/field_slideshow.module).
Warning: getimagesize(): Filename cannot be empty in template_preprocess_field_slideshow() (line 843 of /var/www/hmcc/sites/all/modules/field_slideshow/field_slideshow.module).

This is the warning I get when I have a simple field collection with an Image field:

    Notice: Undefined index: uri in theme_image_formatter() (line 602 of /var/www/hmcc/modules/image/image.field.inc).

Since it is happening in both collection types I suspect it is related. Thanks in advance for your suggestions.

mrprasa’s picture

Version: 7.x-1.x-dev » 7.x-1.0-beta5

I am having this issue of my images in the field collection not displaying in preview mode. Is this still an open issue? I was trying to use field collection for my slideshow and carousels (two separate items - the carousel is not a pager) because I wanted to create multiple slide groups containing an image, caption, and link. It works great except that users can't preview their work. Any suggestions would be greatly appreciated. I am getting the Notice: Undefined index: uri in theme_image_formatter() error.

garamani’s picture

hi mrparsa

I had the same problem and the same warning!
I solved the problem this way:

1. go here: structure>field collections>manage display
2.change the format to: "Rendered file" (notice: I've installed "Media" module)
3.click on the gear icon.
4.change the view mode to: large, small or medium

and 5.save

hope this works for you

colinafoley’s picture

Version: 7.x-1.0-beta5 » 7.x-1.x-dev
Component: User interface » Code
Category: feature » bug
Status: Active » Needs review
FileSize
1.28 KB

So, this seems pretty sloppy to me. I feel like having to get the field_instances and field_info at this step is wrong, but I didn't know how else to do this in a generic way.

This patch works at the FieldCollectionItemEntity level so it fixes this issue for both field_collection and field_collection_table. I chatted with tim.plunkett on IRC and he suggested using hook_field_formatter_prepare_view() initially. I was dissatisfied after exploring this approach because it would have required an additional patch for field_collection_table. Additionally, I really feel the issue is at the FieldCollectionItemEntity level since it seems like sometimes the necessary field data is being loaded (viewing the entity) and sometimes it is not being loaded (previewing the entity).

Please note: This is only a fix for image fields, not all file fields.

madelyncruz’s picture

#7 method doesn't work

madelyncruz’s picture

FileSize
3.71 KB
2.79 KB

I have solved the problem without applying any patches, all you have to do is to add to the 'Relationship' field of it then add the image field to the fields section then select the 'Relationship' of the field collection image field.

Tobias Xy’s picture

My problem was:
I want to preview a node with a "normal" image field and a field collection containing an image field
and I got the Notice: Undefined index: uri in theme_image_formatter() error.
No views included!

For me #7 is working flawlessly, so I guess there are multiple issues?

BTW: During my debugging I came to the solution that field_collection_field_load as an implementation of hook_field_load is missing, but since I'm not very familar with the code of field collections and #7 is working for me, I guess I'm wrong here. ;-)

aucovic’s picture

Patch #7 works well on beta5 module version. I hope they will fix this bug and realase stable version soon.

Thx colinafoley, great work!

colan’s picture

@colinafoley: Thanks for your work on #7. It didn't work for me when adding a new translation with Entity Translation. The language code wasn't coming through. To fix, I got it from the environment.

colan’s picture

Sorry, forgot an isset().

kristofferwiklund’s picture

Status: Needs review » Needs work

The patch did not solve my problem.

- I have a content type with a field collection and inside the field collection is a image field.
- Editing an existing node and uploading a image.
- Clicking the preview button
- Missing image for "Preview full version" and the following error message:
"Notice: Undefined index: uri in theme_image_formatter() (line 602 of /var/aegir/platforms/20140916/modules/image/image.field.inc)."

justanothermark’s picture

Status: Needs work » Needs review
FileSize
1.88 KB

The patch is #13 seems to rely on the field using the language whereas by default it seems to use LANGUAGE_NONE even when the $language_code global is set. I've updated the patch to use LANGUAGE_NONE if the field doesn't contain an array key for the current language.

I've also extended the patch to work for other file fields by merging in the whole of the loaded object and not just the URI.

Arlina’s picture

Patch in #15 works correctly (tested on 7.x-1.0-beta8).

Thanks!

alemadlei’s picture

#15 worked for me too on beta8

alemadlei’s picture

#15 worked for me too on beta8

yce’s picture

Hi!

I've recreated the patch for beta9, and it works great for me too! Thanks!

yce’s picture

FileSize
1.9 KB
yce’s picture

FileSize
1.9 KB

Sorry, I got the comment number right this time :)

jmuzz’s picture

I agree with the original author of this patch @colinafoley that there is likely a better solution. Please test this patch. It worked in for me for an image field inside field collections nested 1 and 2 levels deep on a new unsaved node, but I haven't tested other cases.

Edit: The first line in the function has no purpose and should be removed before committing.

Andrew Answer’s picture

#22 works for me.

jmuzz’s picture

Please test #23.

Even the original author of #22 is not happy with that solution and he explained why when he posted it in #7.

izus’s picture

Title: Image preview missing » Files preview missing and causinh Entitymalformed exception errors
FileSize
2.09 KB

Hi,
I tested patch #23 and it works for Preview of existing content but not when creating a new content.
Following patch is an aggregation of patch #23 + a fix for the new creating nodes.
This is now working for both :)

Oleksiy’s picture

Thanks a lot! Patch #26 works for me on node add preview.

Chris Matthews’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll, +Needs rework

The patch in #26 does not apply to the latest 7.x-1.x dev snapshot and may be too old to reroll, but I went ahead and tagged the issue accordingly.

Hunk #1 succeeded at 666 (offset 124 lines).
error: while searching for:

      $view_mode = !empty($display['settings']['view_mode']) ? $display['settings']['view_mode'] : 'full';
      foreach ($items as $delta => $item) {
        if ($field_collection = field_collection_field_get_entity($item)) {
          $element[$delta]['entity'] = $field_collection->view($view_mode);
          $element[$delta]['#theme_wrappers'] = array('field_collection_view');
          $element[$delta]['#attributes']['class'][] = 'field-collection-view';

error: patch failed: field_collection.module:782
error: field_collection.module: patch does not apply
Andrew Answer’s picture

Andrew Answer’s picture

Title: Files preview missing and causinh Entitymalformed exception errors » Files preview missing and causing EntityMailformedException errors

  • ram4nd committed 354d0c0 on 7.x-1.x authored by yce
    Issue #1447338 by yce, colan, Andrew Answer, jmuzz, colinafoley,...
ram4nd’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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