How to use images for next and previous buttons with Views Slideshow (or, how to replace any textual link with an image)
This tutorial is sponsored by the Save Joseph campaign, a grassroots effort to find a good friend, stellar artist and all around amazing person a satisfying, creative job in the next 9 days. I know the Drupal community could use this kind of talent. Learn more about the effort at savejoseph.org.
Views Slideshow is a nice module that leverages the jQuery Cycle plugin to create a highly-customizable, attractive slideshow. It comes with an option to display simple text controls to go forward or back through the slides. What I wanted was to customize this experience with images instead of the Previous and Next links.
The first step is create a view using Views Slideshow and enable the controls on the top of the slideshow. This is done via the Views style settings dialog:

Once this is set, you should see some links above the slideshow:

To turn these links into images, we first need to find a unique identifier for each one. Views Slideshow adds a unique ID, so we can use that. Here's what I see in Firebug when I inspect the element:

You can see there is a unique ID for each element. Now, all we need to do is set a number of styles for the link.
First, we need to set the background of the element to use our image:
background:url('images/left-button-on.png');Next, we need to set the dimensions of the element to match our image, which is 71 pixels by 71 pixels. If we didn't have to worry about the text, we would just set the width and height. But, we need to hide the text, so we're going to set the height o 0, and the top padding to 71, which will bump the text out of view:
width:71px;
height:0px;
padding-top:71px;If you refresh your page at this point, you'll still see some text:

This is because we need to explicitly set any the element to hide any content that's outside of it's bounds. We do so by defining the overflow property to hidden:
overflow:hidden;Finally, I didn't want a pause button, so I set to not display:
display:none;The final result looks like this:

By the way, the artwork you see is produced by Joseph Cowman, if you haven't seen his stuff, it's brilliant.
And the code, with some particular styles for what I needed, is this:
#views_slideshow_singleframe_prev_gallery-block_1, #views_slideshow_singleframe_next_gallery-block_1 {
width:71px;
height:0px;
padding-top:71px;
position:absolute;
top:100px;
overflow:hidden;
}
#views_slideshow_singleframe_prev_gallery-block_1 {
background:url('images/left-button-on.png');
left:0px;
}
#views_slideshow_singleframe_next_gallery-block_1 {
background:url('images/right-button-on.png');
right:0px;
}
#views_slideshow_singleframe_playpause_gallery-block_1 {
display:none;
}Recent blog entries
Twitter feed:
- Letter to a disgruntled module user http://is.gd/eLI2y1 week ago
- How to easily upgrade Drupal from one minor version to another with a patch file http://is.gd/ezL2s2 weeks ago
- Restarting my mac for the first time in 24 days #fb2 weeks ago
- Why does it always catch me off guard when people don't look like their profile pics? I should be used to this from my internet datin... #fb3 weeks ago
- @rock_soup What command was that?3 weeks ago
- @dale42 A belated agreement about the devil's work in absolute URLs. :)3 weeks ago
- Save the Planet! Well, the Drupal Planet (actually, the Drupal Planet log files) http://is.gd/egxwt3 weeks ago
- The Save Joseph campaign is over, thank you! (plus, summarization of social networking techniques applied) http://is.gd/eb1Y1 #fb4 weeks ago
- @simonsurtees Great re:evernote offer. In next steps I want to improve API and allow for collaborative content creation. Should be fun!4 weeks ago
- Only 12 hours left to Save Joseph - $150 bounty, infinite karma points, excitement abounds! http://savejoseph.org #fb5 weeks ago
Topics
- activism
- apple software
- book reviews
- design
- Drupal
- drupal administration
- drupal community
- drupal events
- drupal modules
- drupal resources
- freaky stuff
- geeky entertainment
- iphone ipod touch
- jquery
- learning
- life hacks
- looping
- maps
- minimalism
- music
- philosophology
- presentations
- productivity
- rambling
- restraint
- software
- theming
- treadmill desk
- usability
- usability testing
- video demonstrations
- web hosting
- original songs
- This American Life
- evernote
Blog archive
- March 2009 (2)
- April 2009 (15)
- May 2009 (10)
- June 2009 (3)
- July 2009 (3)
- August 2009 (6)
- September 2009 (2)
- October 2009 (4)
- November 2009 (3)
- December 2009 (1)
- January 2010 (1)
- March 2010 (1)
- June 2010 (1)
- July 2010 (46)
- August 2010 (5)










Comments
Hi,
Thanks for the above, its exactly what i needed!
Just one question..
Where can i find the CSS &/or HTML location to edit..
Again many thanks
Post new comment