Drupal Tutorials and Blog Posts

Creating a Drupal Slideshow with Views Slideshow

advert-full-class

Views Slideshow is the most popular module for creating slideshows in Drupal.

Earlier this year we showed you how to use Views Slideshow to create a basic slideshow.

One of our students read that tutorial and wondered about taking things further. They wanted to create a slideshow with smaller thumbnails, similar to the one you see on WhiteHouse.gov, Grammy.com and many other Drupal sites. In this tutorial, we show you how to create a more advanced slideshow, similar to those famous sites.

media_1351621668227.png

Step 1: Installation

You're also going to need a single file that contains a JQuery slideshow script. This will need to be uploaded manually.

media_1351543536543.png
  • Download the file which will be called jquery.cycle.all.js
  • Access your site files.
  • Browse to the /sites/all/ folder.
  • Create a folder called /ibraries/ so that the path is /sites/all/libraries/
  • Create a folder called /jquery.cycle/ so that the path is /sites/all/libraries//jquery.cycle/
  • Upload the jquery.cycle.all.js file into that last folder.
media_1351543973645.png

Step 2: Views

We're going to create our slideshow using Views.

  • Go to Structure > Views > Add new view.
  • Check Create a block
  • Choose Slideshow for the Display format
  • Choose 1 for the Items per page
media_1351542979941.png
  • Click Add.
  • Select Image.
  • Click Apply (All displays).
  • Set the Image style to Large. We'll change this again later.
media_1351543165602.png
  • Click Apply (All displays).
  • Click Add.
  • Select Image.
  • Check the box which says Exclude from display.
  • Set the Image style to Thumbnail. We'll also change this later.
  • Click Apply (All displays).
  • Click Content:Title
  • Click Remove

Once you're finished, your fields area should look like the area below.

media_1351548620566.png
  • Find the Format area on the left-hand side of the Views page.
  • Click Settings next to Slideshow.
media_1351548657236.png
  • Scroll down to the cycle options.
  • Check the box Pager under Bottom Widgets.
  • Select the second of the two Image fields as the Pager fields..
media_1351549029523.png
  • Click Apply (All displays).
  • Click Apply (All displays). It should be close to looking like an active slideshow, but it will still have design problems. Your images won't be the perfect size yet and your smaller images will be stached vertically.
media_1351549155895.png
  • In the center of your Views screen, set the Pager so that it contains the number of small iterms you want underneath your main image.
  • Click Save to record all your changes so far.
media_1351551001665.png

Step 3: Design

First, let's set up the correct style for our images:

  • Go to Configuration > Image Styles.
  • Click Add style.
  • Enter slideshow_main
  • Click Create new style
  • Next to Select a new effect, choose Resize and click Add
  • Enter the height and width you'd like for your main slideshow image. Don't worry about getting it exactly right first time. You can always come back and change this size.
  • Click Save

Now let's create the style for our smaller thumbnails.

  • Repeat the process above.
  • This time create a style called slideshow_pager

Now, we'll apply those styles to our View.

  • Go to Structure > Views.
  • Click edit next to your slideshow view.
  • Click on the first Image field and set Image style to slideshow_main
  • Click on the second Image field and set Image style to slideshow_pager

Now click Save and let's go see your slideshow.

  • Go to Structure > Blocks.
  • Publish your view.

The final remaining problem is going to be the vertical images. We can fix that with CSS.

  • Go to your theme's CSS file.
  • Add some code like this:

.views-slideshow-controls-bottom .views-slideshow-pager-field-item { float: left; margin: 5px 19px 0 0; }

As a final step, you will need to tweak your image styles and your CSS to match your design.

Here's my end result, after this tutorial, and using dummy images:

media_1351549934591.png

Comments

 
picturina
#1 picturina 2012-11-07 23:58

This looks helpful, but I your final result image shows that the pictures in the slideshow and thumbnails will be distorted. Most people want to maintain the original aspect-ratio of the images in their slideshow, since distortion give an unprofessional appearance. I wonder if you can address that.
 
 
Joey
#2 Joey 2012-12-17 16:40

Changing images is fairly easy and is done via the inherent image styles menu within Drupal. It should be intuitive enough to add these styles to the pager/thumbnail elements to achieve the desired effect.
 
 
Chriswhite
#3 Chriswhite 2013-01-11 16:41

Hi,

How do we make slideshow like the one that appears at the top of the page?
 
 
steve
#4 steve 2013-01-11 16:43

Hi Chris

This tutorial takes you really pretty close. if you want to move the thumbnails to the side, rather than underneath, you'll need to do some CSS and PHP work to create a custom template for Views Slideshow. The same goes for having the text on top of the image.
 
 
Elfriede
#5 Elfriede 2013-01-12 22:44

Hi nice tutorial, but ehm.. how can I add the images? sry, not a drupal programmer :)
 
 
Chriswhite
#6 Chriswhite 2013-01-15 20:59

Hi Steve,

Thank you for your reply, I managed to move the images using CSS.

I was wondering whether there is a way to make them all smaller when the window is re-sized?

I used:

max-width: 100%;
height: auto;
width: auto\9;

But didn't work, is it because I used a view and the images/thumbnai ls are dynamically added?

Thanks once again!
Chris
 
 
Chriswhite
#7 Chriswhite 2013-01-15 21:01

@Elfriede

You need to have the images set up first, in my case I used the images I had for the products I created, I used the products option to bring up the list and then just selected the fields I required, i.e. images.

Hope this helps.
 
 
girlbert
#8 girlbert 2013-01-26 01:01

Thanks so much for this simple, but crazy-helpful tutorial!
 
 
Elfriede
#9 Elfriede 2013-01-26 09:03

Yes great guys!!! It worked!! Tnx so much.
 
 
criss
#10 criss 2013-02-26 12:50

hei. is it possible to make (with this module) a slideshow like this but having a pager that is also a slideshow which displays 2 pagers one time?
 
 
sosthy
#11 sosthy 2013-03-04 13:19

great tuto but plz how to overlay text on the slideshow
 
 
steve
#12 steve 2013-03-04 13:56

Hi Sosthy

We don't address that in this tutorial but we do in our full Views Slidshow class: ostraining.com/.../slideshow
 
 
kuba
#13 kuba 2013-03-13 01:34

Thanks
 
 
ahmed
#14 ahmed 2013-03-17 09:38

hi there,
i want to change the images/thumbnai layout, how could i ?
thank you.
 
 
Alba
#15 Alba 2013-04-04 15:24

Thanks!
 

Add comment


Security code
Refresh

blog-ad

Start Online Training

Members get access to all our video training. That's 1,244 training sessions in Joomla, Drupal, WordPress and Coding.

Latest Comments

The License for Our Tutorials

All of our tutorials are published under the Creative Commons Attribution-NonCommercial license. This means:

  • You can re-use these tutorials.
  • You can modify these tutorials.
  • You must link back to our original tutorial.
  • You can't use these tutorials commercially.

Click here to read the full license.

Copyright 2013 Open Source Training, LLC. All rights reserved.