In a minute I'll upload a little PoC that adds support for Flexslider 2.2.0 thumbCaptions and also adds support for choosing a field as a caption field in views (needed to support thumbnail captions in views as thumbCaptions uses a data property). If you like this but want thumbCaptions & views captions separated or would prefer it done some other way, please let me know.

Cheers!
JP

Comments

minoroffense’s picture

One patch is fine.

jpstrikesback’s picture

Status: Active » Needs review

Here is the patch.

Note: this also includes the fix in #2029811: Grouping fields are not saved in FlexSlider style options.

jpstrikesback’s picture

Oops, here is the patch.

minoroffense’s picture

Status: Needs review » Needs work

Can you add a note on the option set form indicating that feature requires the FlexSlider library 2.2 or higher.

<em>Requires FlexSlider Library 2.2+</em>

I have a similar piece of text created for the allowOneSlide option once it gets added. You don't have to lock out the field, just warn the user.

Bonus points if you add an element_validate callback we could add to warn on save as well (something like _flexslider_validate_minimum_version_22 as the callback).

At the same time update the patch to exclude the += stuff from the already committed code.

jpstrikesback’s picture

Status: Needs work » Needs review
StatusFileSize
new5.21 KB

Here is the cleanup and the req. note. Just looking into #element_validate.

jpstrikesback’s picture

Here it is with an #element_validate that uses php's version_compare to check against the version returned from libraries_detect().

jpstrikesback’s picture

^^ That also renames the form element title to "Thumbnail Captions" rather than "Use Thumbnail Captions" as nouns seem the way to go...

minoroffense’s picture

Assigned: Unassigned » minoroffense
minoroffense’s picture

Status: Needs review » Needs work

Well done! One bug in the code though.

Looking at the docs for version compare, we'll need to add the operator argument. As it stands the validation will fail if the version is lower or higher than 2.2. In our case we want anything higher or equal to pass and fail below.

Use the "ge" option (or the symbolic version)

http://php.net/manual/en/function.version-compare.php

jpstrikesback’s picture

Cheers! That was bothering me as well!

jpstrikesback’s picture

Status: Needs work » Needs review
StatusFileSize
new5.9 KB

I used '>=' as the op rather than 'ge' as it seems a little easier to read/understand. Thanks for the help!

minoroffense’s picture

I adjusted some of the code a bit and fixed some bugs with Views. Can you try this out? Should be good to go.

jpstrikesback’s picture

Looks good from a read, but I'll give it a shot later tonight.

Cheers

jpstrikesback’s picture

One minor problem:

+++ b/theme/flexslider.theme.incundefined
@@ -145,7 +145,12 @@ function template_process_flexslider_list_item(&$vars) {
-  if (!empty($caption)) {
+  if (($settings['optionset']->options['thumbCaptions']) && !empty($caption)) {
+    $attributes['data-thumbcaption'] = $caption;
+    // remove the caption so that it doesn't show in both places
+    $caption = '';
+  }
+  elseif (!empty($caption)) {
     $caption = '<p class="flex-caption">' . $caption . '</p>';
   }
 }

$settings['optionset']->options['thumbCaptions'] isn't necessarily set and throws a notice for a bunch of the examples.

So something like:

-  if (!empty($caption)) {
+  $thumbcaptions = !empty($settings['optionset']->options['thumbCaptions']) ? $settings['optionset']->options['thumbCaptions'] : FALSE;
+  if ($thumbcaptions && !empty($caption)) {
+    $attributes['data-thumbcaption'] = $caption;
+    // remove the caption so that it doesn't show in both places
+    $caption = '';
+  }
+  elseif (!empty($caption)) {
     $caption = '<p class="flex-caption">' . $caption . '</p>';
   }
 }
minoroffense’s picture

Right of course. Duh me.

jpstrikesback’s picture

Haha, that little bit is my fault...I just haven't had a moment to switch gears and work on it again...

minoroffense’s picture

I pushed the 2074499 branch. You can checkout the code from there if need be.

minoroffense’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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