views:

429

answers:

1

What I would like to do is dictate where my thumbnails are instead of using the main images as the thumbnail.

I'm pretty sure this can be done, I just need a little push in the right direction.

Here is my Code:

<script type="text/javascript">

$('#imageContainer').before('').cycle({ fx: 'fade', speed: 2000, timeout: 8000, pager: '#nav',

// callback fn that creates a thumbnail to use as pager anchor 
pagerAnchorBuilder: function(i, slide) { 
    return '<li><a href="#"><img src="' + slide.src + '" width="121" height="67" /></a></li>'; 
}

});

And here is the HTML:

<div id="container">
<div id="imageContainer">
    <img src="http://www.ifcj.org/ifcj-08/images/elements/slideshow/1.jpg"  rel="http://www.ifcj.org/ifcj-08/images/elements/slideshow/1t.jpg" width="378" height="210" />
    <img src="http://www.ifcj.org/ifcj-08/images/elements/slideshow/2.jpg" rel="http://www.ifcj.org/ifcj-08/images/elements/slideshow/2t.jpg" width="378" height="210" />
    <img src="http://www.ifcj.org/ifcj-08/images/elements/slideshow/3.jpg" rel="http://www.ifcj.org/ifcj-08/images/elements/slideshow/3t.jpg" width="378" height="210" />
</div>
<div id="nav"></div>

Any help would do.

thank You

+1  A: 

If you're talking about a scenario like the one described here http://malsup.com/jquery/cycle/pager2.html, you should be able to do something like the following:

pagerAnchorBuilder: function(id, slide) { 
 var thumb_prefix = "t_";
 return '<li><a href="#"><img src="' + thumb_prefix + slide.src + '" width="50" height="50" /></a></li>';
}

This is the simplest example, of course you can do something different depending on your naming convention and particular application, for example inserting a t at the end before the extension:

pagerAnchorBuilder: function(id, slide) { 

 // Split off the filename with no extension (period + 3 letter extension)
 var new_src = slide.src.substring(0,slide.src.length-4);

 // Add the "t"
 new_src += "t";

 // Add the period and the 3 letter extension back on
 new_src += slide.src.substring(slide.src.length-4,slide.src.length);

 // Set this as the source for our image
 return '<li><a href="#"><img src="' + new_src + '" width="50" height="50" /></a></li>';
}
sparkey0
Thank you!!! If I could ask one more question.I would like to add this "t" to the end of the file src for example:Before adding "t":<img src="http://www.ifcj.org/ifcj-08/images/elements/slideshow/1.jpg" width="378" height="210" />After adding "t":<img src="http://www.ifcj.org/ifcj-08/images/elements/slideshow/1t.jpg" width="378" height="210" />
Matthew
Okay thay didn't come out right.I need to add this "t" to the image src path but before the image extension so it reads as such: /1t.jpg
Matthew
Hard to read as a comment -- will add to the original post.
sparkey0
Thanks again!!!
Matthew
Hey one last question I know that you have helped me out here a lot but wanted to know how I can go about adding links to the large images. Using the onAfter function is the way... but i'm not seeing a solid example. So if anyone can point me in the right way that would be great. thanks!
Matthew