diff --git a/field_collection.module b/field_collection.module index 645093a..6befecf 100644 --- a/field_collection.module +++ b/field_collection.module @@ -574,6 +574,28 @@ class FieldCollectionItemEntity extends Entity { } } + public function view($view_mode = 'full', $langcode = NULL, $page = NULL) { + // Ensure file fields on the entity have their URI loaded for previews. + if ($langcode == NULL) { + $langcode = LANGUAGE_NONE; + } + // Iterate over fields in the collection to add URI for image fields + $field_instances = field_info_instances($this->entityType, $this->field_name); + foreach ($field_instances as $field_name => $field) { + $info = field_info_field($field_name); + if ($info['type'] == 'image' && $image_field = &$this->$field_name) { + // Add the URI to the field on the entity for display + foreach ($image_field[$langcode] as &$field_to_be_updated) { + if (!isset($field_to_be_updated['uri'])) { + $image = file_load($field_to_be_updated['fid']); + $field_to_be_updated['uri'] = $image->uri; + } + } + } + } + return entity_get_controller($this->entityType)->view(array($this), $view_mode, $langcode, $page); + } + /** * Export the field collection item. *