Hi,
I'm currently using drupal plugins to make a content type image field as responsive. It works ok.
When rendering, the expected java code is generated. When it is a first level field is works fine:
print render($content['field_imagen']);
I'm also using the field collections module in order to create repetitive field blocks inside a content type. I can access all this information. Both modules work ok.
My problem arises when trying to generate a responsive image inside a field collection. I have no way to render the image.
To go through the filed collection I'm using the following code but in the last field (responsive image) I only get information about the initial image but it doesn't render:
// Get the field collection items. $fc_fields = field_get_items('node', $node, 'field_columna'); // Extract the field collection item ids $ids = array(); foreach ($fc_fields as $fc_field) { $ids[] = $fc_field['value']; } // Load up the field collection items $items = field_collection_item_load_multiple($ids); // Loop through the items and extract field values foreach ($items as $item) { $site_name_fields = field_get_items('field_collection_item', $item, 'field_texto'); $site_name = array_shift($site_name_fields); $name = $site_name['value']; print render($name); $site_name_fields = field_get_items('field_collection_item', $item, 'field_imagen_fija'); $site_name = array_shift($site_name_fields); $name = $site_name['filename']; $uri = 'public://'; $path= file_create_url($uri).$name; echo '<img src="'.$path.'">'; $site_name_fields = field_get_items('field_collection_item', $item, 'field_imagen_col'); $site_name = array_shift($site_name_fields); $name = $site_name['filename']; print render($name); }
Plugin and images information are in the database because the next code generates responsive images rendering but for all the collection though I want to render only the image:
$rendered = drupal_render(field_view_field('node', $node, 'field_columna'));
print render($rendered);
Any help will be very appreciated.
Thank you.
Comments
Comment #1
jmuzz CreditAttribution: jmuzz commentedYour code looks like on commented out line. Could you format it so it can be read?
Please read the instructions under the "Issue tags" field.
Comment #2
jmuzz CreditAttribution: jmuzz commentedComment #3
jmuzz CreditAttribution: jmuzz commentedTry using field_view_field on the field collection item and its image subfield rather than the node.
Hope this helps.