Skip to content

Instantly share code, notes, and snippets.

@albell
Last active December 15, 2015 00:29
Show Gist options
  • Save albell/5173623 to your computer and use it in GitHub Desktop.
Save albell/5173623 to your computer and use it in GitHub Desktop.
<div class="cycle-slideshow"
data-slides=">div"
data-cycle-auto-height="calc"
>
<div>
<img src="img1.jpg" width="###" height="###">
<p>caption 1</p>
</div>
<div>
<img src="img2.jpg" width="###" height="###">
<p>caption 2</p>
</div>
<div>
<img src="tiniest.gif" data-src="img3.jpg" width="###" height="###">
<p>caption 3</p>
</div>
<div>
<img src="tiniest.gif" data-src="img4.jpg" width="###" height="###">
<p>caption 4</p>
</div>
</div>
$('.cycle-slideshow').on( 'cycle-before', function(e, optionHash, outgoingSlideEl, incomingSlideEl, forwardFlag ) {
// the slide after the next slide
futureSlideContents = $(optionHash.slides[optionHash.nextSlide + 1]);
// if the slide has descendants, replace with its descendant imgs
if (futureSlideContents.children().length) {
futureSlideContents = futureSlideContents.find('img');
}
futureSlideContents.each(function() {
// if the source contains "tiniest.gif", replace src with the data-src
if ($(this).attr("src").indexOf("tiniest.gif") >= 0) {
$(this).attr("src", $(this).attr("data-src")); //
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment