Created
February 27, 2009 09:55
-
-
Save yoko/71383 to your computer and use it in GitHub Desktop.
yet another jQIR.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
var options = { | |
path: '/img' | |
}; | |
$.replaceImageSetup = function(o) { | |
options = o; | |
}; | |
$.fn.replaceImage = function(ext) { | |
return this.each(function() { | |
if (!this.id) return; | |
var self = $(this); | |
var img = $('<img/>'); | |
var src = options.path+'/'+this.id+'.'+ext; | |
img.attr({ | |
src: src, | |
alt: self.text() | |
}); | |
var a = $('a', self); | |
var element = a.length ? a.eq(0).html(img) : img; | |
self.html(element); | |
}); | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment