I'm trying to create a ‘Gallery’ Paragraphs bundle with multi-value image field using Flex Slider to display a slideshow.

If I select flexslider display formatter (any options set) for the field I get a nice slideshow or carousel but the last image is missing. Any number of images, the last is just "/files/styles/flexslider_thumbnail/public?itok=_dEJoYW0" which is 404 not found of course.

If there's only one image added to the field I get the same 404 and no image.

Here's where it all happens

      // Render the slide item
      // If not style set, we have to call theme_image since theme_image_style
      // doesn't auto-fallback to full size image
      if (!empty($item['slide']['style_name'])) {
        // Generate the HTML for the slide
        $item['slide'] = theme('image_style', $item['slide']);
      }
      else {
        // Generate the HTML for the slide
        $item['slide'] = theme('image', $item['slide']);
      }

Looks like the last items were already processed up to this point

array(2) { < -------- this one is OK
  ["item"]=>
  array(17) {
    ["fid"]=>
    string(2) "25"
    ["uid"]=>
    string(1) "1"
    ["filename"]=>
    string(5) "5.jpg"
    ["uri"]=>
    string(21) "public://images/5.jpg"
    ["filemime"]=>
    string(10) "image/jpeg"
    ["filesize"]=>
    string(6) "134917"
    ["status"]=>
    string(1) "1"
    ["timestamp"]=>
    string(10) "1412053147"
    ["type"]=>
    string(5) "image"
    ["uuid"]=>
    string(36) "0263cd39-00d0-4c60-b6bf-7daed8170324"
    ["field_file_image_alt_text"]=>
    array(0) {
    }
    ["field_file_image_title_text"]=>
    array(0) {
    }
    ["metadata"]=>
    array(2) {
      ["height"]=>
      int(342)
      ["width"]=>
      int(598)
    }
    ["alt"]=>
    NULL
    ["title"]=>
    NULL
    ["width"]=>
    string(3) "598"
    ["height"]=>
    string(3) "342"
  }
  ["slide"]=>
  array(4) {
    ["path"]=>
    string(21) "public://images/5.jpg"
    ["style_name"]=>
    string(20) "flexslider_thumbnail"
    ["width"]=>
    string(3) "598"
    ["height"]=>
    string(3) "342"
  }
}

array(2) { <--- this one is not OK!
  ["item"]=>
  array(2) {
    ["item"]=>
    array(17) {
      ["fid"]=>
      string(2) "26"
      ["uid"]=>
      string(1) "1"
      ["filename"]=>
      string(5) "6.jpg"
      ["uri"]=>
      string(21) "public://images/6.jpg"
      ["filemime"]=>
      string(10) "image/jpeg"
      ["filesize"]=>
      string(5) "85685"
      ["status"]=>
      string(1) "1"
      ["timestamp"]=>
      string(10) "1412053168"
      ["type"]=>
      string(5) "image"
      ["uuid"]=>
      string(36) "a3293240-1ea9-4223-8d67-911cffac1f3b"
      ["field_file_image_alt_text"]=>
      array(0) {
      }
      ["field_file_image_title_text"]=>
      array(0) {
      }
      ["metadata"]=>
      array(2) {
        ["height"]=>
        int(342)
        ["width"]=>
        int(598)
      }
      ["alt"]=>
      NULL
      ["title"]=>
      NULL
      ["width"]=>
      string(3) "598"
      ["height"]=>
      string(3) "342"
    }
    ["slide"]=>
    string(188) "<img class="flexslider-thumbnail img-responsive" src="STRIPPED/files/styles/flexslider_thumbnail/public/images/6.jpg?itok=h4vDcpVr" width="160" height="100" alt="" />"
  }
  ["slide"]=>
  array(1) {
    ["style_name"]=>
    string(20) "flexslider_thumbnail"
  }
}

So item['slide'] is a string and theme() functions don't work as they should.

Comments

scoff’s picture

Title: Flex Slider and Paragraphs » Flex Slider and Paragraphs and Panelizer

More details.
Looks like Panelizer is responsible for this. When Paragraph item with a FlexSlider field inside is attached to a node that is Panelized (panelize is enabled for it's content type), the flexslider_fields_field_formatter_view gets executed several times, one time per each panelized view mode, I suppose. It doesn't matter if the current view mode (like full page override) is panelized or not. Disabling Panelizer solves the problem if you can call it a solution.

I've also tried the field slideshow module and it works fine. It's also affected by Panelizer, but it always returns the same result even if it's called multiple times.

A quick hack

In flexslider_fields_field_formatter_view check if $item['item'] exists and skip processing if it does

foreach ($items as $key => $item) {
      if(isset($item['item'])) continue; 
      $tmp = $item;
      $item = array();
      $item['item'] = $tmp;
...
micbar’s picture

Status: Active » Needs review
Related issues: +#2450059: Panelizer Error
StatusFileSize
new517 bytes
HaiNguyen007’s picture

Confirm patch #2 worked
And this problem is panels related (not only panelizer)
When I add paragraphs bundle have flexslider as formatter of a field to a panelizered node/ a mini-panels / a panels I get same error in this issue. So I update this issue to reflect that

HaiNguyen007’s picture

Title: Flex Slider and Paragraphs and Panelizer » Flex Slider and Paragraphs and Panels (Panelizer/mini-panels/page_manager pages)
Status: Needs review » Reviewed & tested by the community
HaiNguyen007’s picture

Patch #2 ensure flexslider_fields_field_formatter_view() excute only one for each slide image => result of render array of slide always correct (ex: not transfrom to a string) => good enough solution

minoroffense’s picture

Status: Reviewed & tested by the community » Fixed

  • minorOffense committed c6bc698 on 7.x-2.x authored by micbar
    Issue #2347379 by micbar: Flex Slider and Paragraphs and Panels (...

Status: Fixed » Closed (fixed)

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