diff --git a/flexslider_fields/flexslider_fields.module b/flexslider_fields/flexslider_fields.module index fddc835..d829ed4 100644 --- a/flexslider_fields/flexslider_fields.module +++ b/flexslider_fields/flexslider_fields.module @@ -133,14 +133,17 @@ function flexslider_fields_field_formatter_view($entity_type, $entity, $field, $ $tmp = $item; $item = array(); $item['item'] = $tmp; - + // Setup the variables for calling theme_image_style $item['slide']['path'] = $item['item']['uri']; - $item['slide']['style_name'] = $display['settings']['image_style']; $item['slide']['width'] = $item['item']['width']; $item['slide']['height'] = $item['item']['height']; $item['slide']['alt'] = $item['item']['alt']; $item['slide']['title'] = $item['item']['title']; + + // Load the optionset to extract image styles + $optionset = flexslider_optionset_load($display['settings']['optionset']); + $item['slide']['style_name'] = $optionset->imagestyle_normal; // Render the slide item // If not style set, we have to call theme_image since theme_image_style @@ -159,6 +162,11 @@ function flexslider_fields_field_formatter_view($entity_type, $entity, $field, $ $item['caption'] = filter_xss($item['item']['title']); } + // Add the thumbnail url according to the optionset confirguration + if ($optionset->imagestyle_thumbnail) { + $item['thumbnail_url'] = image_style_url($optionset->imagestyle_thumbnail, $item['item']['uri']); + } + $items[$key] = $item; } diff --git a/theme/flexslider.theme.inc b/theme/flexslider.theme.inc index c3b27d4..641a806 100755 --- a/theme/flexslider.theme.inc +++ b/theme/flexslider.theme.inc @@ -30,6 +30,7 @@ function theme_flexslider_list(&$vars) { $output .= theme('flexslider_list_item', array( 'item' => $item['slide'], + 'thumbnail_url' => isset($item['thumbnail_url']) ? $item['thumbnail_url'] : FALSE, 'settings' => array( 'optionset' => $optionset, ), @@ -134,13 +135,10 @@ function template_process_flexslider_list_item(&$vars) { // Generated thumbnail support if (isset($settings['optionset']->options['controlNav']) and $settings['optionset']->options['controlNav'] === "thumbnails") { - // If the thumbnails are enabled in the option set, scan for the first img - // tag and extract the src attribute to set as the thumbnail data - $src = array(); - preg_match("", $item, $src); - - if (!empty($src[1])) { - $attributes['data-thumb'] = $src[1]; + // If the thumbnails are enabled in the option set, check to see if a + // thumbnail url has been provided and set that as the thumbnail data. + if ($vars['thumbnail_url']) { + $attributes['data-thumb'] = $vars['thumbnail_url']; } }