Just testing 2.x-dev. If I choose an image field from a field collection, the image source is output with the correct directory path but no filename component.

It looks like this code from template_preprocess_field_slideshow() is tripping things up:

    // Generate the image html
    $image = array();
    $image['path'] = $item['uri'];
    $image['attributes']['class'] = array('field-slideshow-image', 'field-slideshow-image-' . (1+$num));
    $image['alt'] = isset($item['alt']) ? $item['alt'] : '';
    if (isset($item['width']) && isset($item['height'])) {
      $image['width'] = $item['width'];
      $image['height'] = $item['height'];
    }
    elseif ($item["type"] == 'image') {
      $image_dims = getimagesize($image['path']);
      $image['width'] = $image_dims[0];
      $image['height'] = $image_dims[1];
    }
    else {
      $image = array(
        'width' => 0,
        'height' => 0
      );
    }

In my case, $item has a path but no width or height, and $item['type'] is not set.

Comments

johnpitcairn’s picture

Issue summary: View changes
johnpitcairn’s picture

The check for $item['type'] is new in 2.x it seems. In 1.x, the code looked like this:

    // Generate the image html
    $image = array();
    $image['path'] = $item['uri'];
    $image['attributes']['class'] = array('field-slideshow-image', 'field-slideshow-image-' . (1+$num));
    $image['alt'] = isset($item['alt']) ? $item['alt'] : '';
    if (isset($item['width']) && isset($item['height'])) {
      $image['width'] = $item['width'];
      $image['height'] = $item['height'];
    }
    else {
      $image_dims = getimagesize($image['path']);
      $image['width'] = $image_dims[0];
      $image['height'] = $image_dims[1];
    }
johnpitcairn’s picture

In field_slideshow_field_formatter_view(), when the field type is tested for field collection support, I think we should add $items[$delta]['type'] = 'image'. There isn't anything else it can be at this stage, because the settings form only allows selection of an image field from within the field collection.

Patch to come.

johnpitcairn’s picture

And patch (1 line).

johnpitcairn’s picture

Status: Active » Needs review
adammichaelroach’s picture

Patch from #4 worked for me when the images weren't showing on a slideshow for a field collection.

johnpitcairn’s picture

Thanks. Please set the status to RTBC. I'll get scolded if I do it ;-)

johnpitcairn’s picture

This patch in combination with the Picture support patch at #2268419: Enable picture support will break the field structure in a fairly bizarre way. Perhaps this is not the way to go about it.

johnpitcairn’s picture

Status: Needs review » Needs work
johnpitcairn’s picture

Status: Needs work » Needs review
StatusFileSize
new1.07 KB

Setting the item type to "image" is not the way to go. This patch sets the item type to "field_collection", and explicitly tests for that in preprocess. It will play nice with the Picture support patch.

Alexandre360’s picture

Status: Needs review » Reviewed & tested by the community

I confirm the issue and I confirm that the patch fix the problem. Should be commited.

shenzhuxi’s picture

Status: Reviewed & tested by the community » Fixed

Seems it has been fixed.

Status: Fixed » Closed (fixed)

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