when you have an image inside the field collection and
do a preview of the node, the image doesn't appear.

Is there a solution for this behavior?

Thank you!


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
1.28 KB
PASSED: [[SimpleTest]]: [MySQL] 132 pass(es). View

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

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.

Sorry for the bad english. I'm not good in grammar :D

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

Issue summary: View changes
2.04 KB
PASSED: [[SimpleTest]]: [MySQL] 132 pass(es). View

@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

2.11 KB
PASSED: [[SimpleTest]]: [MySQL] 132 pass(es). View

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
1.88 KB
PASSED: [[SimpleTest]]: [MySQL] 164 pass(es). View

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).


alemadlei’s picture

#15 worked for me too on beta8

alemadlei’s picture

#15 worked for me too on beta8

yce’s picture

1.9 KB
PASSED: [[SimpleTest]]: [MySQL] 166 pass(es). View


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

yce’s picture

1.9 KB
PASSED: [[SimpleTest]]: [MySQL] 166 pass(es). View
yce’s picture

1.9 KB
PASSED: [[SimpleTest]]: [MySQL] 166 pass(es). View

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

jmuzz’s picture

1.02 KB
PASSED: [[SimpleTest]]: [MySQL] 166 pass(es). View

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
2.09 KB

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.