The following code will convert the height of thumbnail to the large image's height more dynamically.
Code:
var sizes = {57:319, 76:365, 99:385}; // 57=thumb height, 319=corresponding large image height etc.
$('#thumbs img').live('click', function(){
$('#largeImage').attr('src',$(this).attr('src').replace(/46x([\d]+)/,function(match,thumbHeight){
// use the size in "sizes" if it exists, else use the same height as the thumb
return '199x'+(sizes[thumbHeight] || thumbHeight);
}));
});
Maybe you'd want to fetch or calculate the large image height in some other way, but this is how you can use regular expressions to change the image url.
Bookmarks