I have created a custom field where media file url/location is stored using wordpress standard media gallery pop up by clicking "insert into post" button. Below is my code to extract the path of the media file. Image url is working fine. But it is returning only media title. I don't know where can I get the file path from.
jQuery(document).ready(function() {
jQuery('#wsp_media_button').click(function() {
formfield = jQuery('#wsp_media').attr('name');
tb_show('', 'media-upload.php?TB_iframe=true&tab=library');
return false;
});
window.send_to_editor = function(html) {
var imgurlar = html.match(/<img[^>]+src=\"([^\"]+)\"/);
var imgurl = imgurlar[1];
//html is returning only title of the media
alert(html);
//image
if( imgurl.length ){
jQuery('#wsp_media').val(imgurl);
}
//other types of files
else{
var fileurl = jQuery(html);
}
}
});