I recently received a request to have the timeout of each slideshow slide customizable. I know you can do this by using the timeoutFn advanced option and a bit of jQuery magic, but I thought it might be a nice feature for Views Slideshow Cycle so I patched it. The patch provides the following:

- A new option on the slideshow settings page to choose a timeout "mode". (static or dynamic)
- If 'static' is chosen (which is default) the regular timeout field is visible
- If 'dynamic' is chosen, a set of radio buttons is shown that let's the user choose which field contains the timeout value. (The field must be a part of the view)

The patch is against 7.x-3.x (2012-Mar-26)

Let me know what you think!



drclaw’s picture

new7.47 KB

Sorry, made a little '#states' mistake in that last one. This one is better. Sorry!

drclaw’s picture

new7.08 KB

Apparently I've never used states before. Sorry, this one's better. =/

drclaw’s picture

Category:feature» support

Any thoughts on this? No Rush, just wondering because right now my module's hacked and it would be good to know if you'll even consider this... =)


GreenSkunk’s picture

Hello @drclaw thank you for sharing. I saw your post on the Views_slideshow issue "Rotate after Video plays entirely".

I'm about to apply your latest patch but I have a question. Will the timeout default to the slideshow's default timeout when the "dynamic" timeout field is not set for the current slide?

Use case:

Site uses Views Slideshow to display County events and activities in Full Screen (actually scalable by width) as a digital billboard. Currently, is a slideshow of 1920x1080 images but have a request to add in video.
Slides display, by default, for over 10 seconds. This is important as we want maintainers to just add content and not worry about the duration. The view can use the video's Duration field.

So I'll be trying this out today and I'll report back!

GreenSkunk’s picture

Bad News: Well, since this slideshow is using Drupal 7 I tried out the Media Module (does not provide video durations) and not using the Embedded Video Module (has a duration field for videos(those video hosts that do)). Maybe I'll switch the setup if my current implementation does not fit. The Media module is nice though as it allows your users to either upload a video OR select a video from the web (using the various media module add-ons, like media_youtube and media_vimeo).

Great News: Your patch works @drclaw!

I added a Slide Duration field that is a date field that collects Minutes and Seconds for maintainers to use. Using a time field makes it easy for anyone to enter a video's duration instead of in milliseconds.

Modified the patch for the theme/views_slideshow_cycle.theme.inc to turn the time field into milliseconds. dpm() functions left in there for people to test their slideshows with.

if ($settings['timeout_mode'] == 'dynamic') {
        //dpm(strip_tags($view->render_field($settings['timeout_dynamic_field'], $count)), "views_slideshow timeout dynamic field");
        // remove those tags as we just want the time
        $timeout_time = strip_tags($view->render_field($settings['timeout_dynamic_field'], $count));
        //dpm("Timeout:".$timeout_time, "views_slideshow timeout dynamic field");
        // we only want to break up valid times
        if (strstr($timeout_time, ':') !== FALSE) {
          list($tmpMin, $tmpSec) = explode(':', $timeout_time);
          //dpm("Min:".$tmpMin." Sec:".$tmpSec, "views_slideshow timeout dynamic field");
          $timeout_time = (((int) $tmpMin*60)+((int) $tmpSec)) * 1000;
        } else {
          $timeout_time = (int)$timeout_time;
        // if timeout_time is 0 then set it to the default
        $timeout_time = ($timeout_time==0?$settings['timeout']:$timeout_time);
        //dpm("Timeout_time:".$timeout_time, "views_slideshow timeout dynamic field");
        $settings['timeout_dynamic_items'][$slideshow_count] = $timeout_time;

Now, on to formatting the video so that it scales and playing upon loading of a slide!

Tyera’s picture

Version:7.x-3.x-dev» 7.x-3.0

I just tested this patch, and it works great for me! Thank you so much, drclaw.

How could I set a default timeout to apply if the Timeout Field is blank?

drclaw’s picture

The patch would probably have to be modified for a default value to be configured through Views Slideshow. However, you could add a default value to the field itself through the Field UI instead. This could work as an interim solution...

GreenSkunk’s picture

I'm sorry but I missed those responses. It is still working great!

To get a default_timeout for empty timeout fields please refer to the modifications I made in #5.

// if timeout_time is 0 then set it to the default
        $timeout_time = ($timeout_time==0?$settings['timeout']:$timeout_time);
        //dpm("Timeout_time:".$timeout_time, "views_slideshow timeout dynamic field");
        $settings['timeout_dynamic_items'][$slideshow_count] = $timeout_time;

After applying the modifications in #5 you can simply just use the Views Slideshow's Timer Delay:
To set a default timeout simply do the following in your View's Slideshow Settings (screenshot attached):

  1. Timeout Mode -> Select Static
  2. Set Timer Delay (this is your default in case the dynamic field has no value)
  3. Timeout Mode -> Select Dynamic
  4. Select your Timeout Field

Thank you @drclaw for the dynamic timeout patches!

amara84’s picture

Hello @drclaw and @GreenSkunk,

I'm am quite new into Drupal7, so I apologize in advanced if my question sounds stupid.
I was wondering in which file of the view slideshow we have to copy and paste the patch?

Many thanks