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
Comment #1
scoff commentedMore 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
Comment #2
micbar commentedComment #3
HaiNguyen007 commentedConfirm 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
Comment #4
HaiNguyen007 commentedComment #5
HaiNguyen007 commentedPatch #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
Comment #6
minoroffense commented