Couldn\'t come up with a good title for this.
I\'ve got a build in WordPress where I have multiple image uploads using the built in WordPress media uploader. How it\
Here is my rendition:
It also allows you to insert PDF's files or anything without a SRC attribute by doing a check for img src and if none, trying href on the document. This one also allows you to use classes and apply this to multiple items.
The Javascript:
var formfield = "";
jQuery('.browse_upload').click(function() {
formfield = jQuery(this).attr('name');
tb_show('', 'media-upload.php?type=image&TB_iframe=true');
return false;
});
window.send_to_editor = function(html) {
hrefurl = jQuery('img',html).attr('src');
if(jQuery(hrefurl).length == 0) {
hrefurl = jQuery(html).attr('href'); // We do this to get Links like PDF's
}
jQuery('.' + formfield).val(hrefurl);
tb_remove();
}
Sample HTML