Skip to content

Instantly share code, notes, and snippets.

@juque
Created February 6, 2012 19:08
Show Gist options
  • Select an option

  • Save juque/1754125 to your computer and use it in GitHub Desktop.

Select an option

Save juque/1754125 to your computer and use it in GitHub Desktop.
Show the image filename as a legend in modal window
/*
* Bootic.net
* Show the image filename as a legend in modal window
*/
var showVariantName = (function(){
function getVariantName(url) {
var reImg = /(\d+)-([^?]*)/;
var reStripExt = /(.*)\.[^.]+$/;
var reCleanName = /_+|-+/g;
return url.split("/").pop().match(reImg)[2].match(reStripExt)[1].replace(reCleanName,' ');
}
$('#product-gallery li a').each(function(){
var newName = getVariantName(this.href);
$(this).attr('title',newName);
})
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment