I posted a demo for you. As much as I like qTip, it isn't easy to figure out how to set it up to grab content from within the current HTML.. I spent 20 minutes messing with it until I gave up. But, good news is I do know that this tooltip script has three versions, and one is specifically made for image previews.
So you'll need to reformat your HTML a bit. the href
in the <a>
contains the large image that shows up in the tooltip while the <img src>
contains the thumbnail. You can also include a caption in the tooltip by adding text/HTML into the title attribute of the link (see the first image in the code below).
HTML
<div id="demo">
<ul id="sortable">
<li><a class="preview" href="01.gif" title="This image has a caption"><img src="01.gif" /></a></li>
<li><a class="preview" href="02.gif"><img src="02.gif" /></a></li>
<li><a class="preview" href="03.gif"><img src="03.gif" /></a></li>
<li><a class="preview" href="04.gif"><img src="04.gif" /></a></li>
<li><a class="preview" href="05.gif"><img src="05.gif" /></a></li>
<li><a class="preview" href="06.gif"><img src="06.gif" /></a></li>
<li><a class="preview" href="07.gif"><img src="07.gif" /></a></li>
<li><a class="preview" href="08.gif"><img src="08.gif" /></a></li>
<li><a class="preview" href="09.gif"><img src="09.gif" /></a></li>
<li><a class="preview" href="10.gif"><img src="10.gif" /></a></li>
</ul>
</div>
CSS
.preview { cursor:pointer; }
#preview {
color: #ddd;
background: #222;
border: 1px solid #333;
padding: 5px;
display: none;
opacity: 0.9;
filter: alpha(opacity=90);
text-align: center;
}
Script
$(document).ready(function(){
$("#sortable").sortable();
$("#sortable").disableSelection();
});
// You should load the image preview script below separately
// but I've included it here for completeness
/*
* Image preview script
* powered by jQuery (http://www.jquery.com)
*
* written by Alen Grakalic (http://cssglobe.com)
*
* for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
*
*/
this.imagePreview = function(){
/* CONFIG */
xOffset = 10;
yOffset = 30;
// these 2 variable determine popup's distance from the cursor
// you might want to adjust to get the right result
/* END CONFIG */
$("a.preview").hover(function(e){
this.t = this.title;
this.title = "";
var c = (this.t != "") ? "<br/>" + this.t : "";
$("body").append("<p id='preview'><img src='"+ this.href +"' alt='Image preview' />"+ c +"</p>");
$("#preview")
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px")
.fadeIn("fast");
}, function(){
this.title = this.t;
$("#preview").remove();
});
$("a.preview").mousemove(function(e){
$("#preview")
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px");
});
};
// starting the script on page load
$(document).ready(function(){
imagePreview();
});