<input style="width: 30%;" class="custom_media_url" type="text" name="attachment_url" value="">
<input type="button" value="上传图片" class="custom_media_upload" />
<script>
jQuery('.custom_media_upload').click(function() {
var send_attachment_bkp = wp.media.editor.send.attachment;
wp.media.editor.send.attachment = function(props, attachment) {
jQuery('.custom_media_image').attr('src', attachment.url);
jQuery('.custom_media_url').val(attachment.url);
jQuery('.custom_media_id').html(attachment.id);
wp.media.editor.send.attachment = send_attachment_bkp;
}
wp.media.editor.open();
return false;
});
</script>
wordpress如何实现上传图片的代码
最新推荐文章于 2024-08-05 00:50:28 发布