【发布时间】:2012-02-16 17:42:52
【问题描述】:
我创建了一个自定义字段,通过单击“插入帖子”按钮,使用 wordpress 标准媒体库弹出存储媒体文件 url/位置的字段。下面是我提取媒体文件路径的代码。图片网址工作正常。但它只返回媒体标题。我不知道从哪里可以得到文件路径。
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);
}
}
});
【问题讨论】: