Hi,
I'm loading a background image into a div. Is it possible to get the dimensions from this image?
I'm trying to make a function that will replace text with images on the fly, for use in the menu.
$.fn.MenuImages = function() {
return this.each(function(i) {
var name = $(this).find('a').attr('title');
$(this).css("background-image","url(images/menu-"+name+"-h.png)");
});
};
Problem is that the images do not all have the same size. I'm not sure how to read the file's dimensions unless i load it in a hidden div or something, but that sounds so dirty. Any recommendations? Thanks!
Fixed:
$.fn.MenuImages = function() {
return this.each(function(i) {
var link = $(this).find('a');
var name = link.attr('title');
link.html("<img src='images/menu-"+name+"-h.png' />");
});
};