2
我有問題了解如何實現新的WP媒體上傳器到我的主題選項頁面。是否有關於如何做到這一點的文檔或什麼是如此的解釋?我已經看到了一些如何做到這一點的示例,但沒有一個關於它們的代碼有任何好的解釋。是否有選項列表如何自定義媒體上傳框架?我的意思是,那豈不是很好,如果你可以做這樣的事情(見//創建媒體框架):3.5 Wordpress媒體上傳器手動執行
// Uploading files
var file_frame;
jQuery('.upload_image_button').live('click', function() {
// If the media frame already exists, reopen it.
if (file_frame) {
file_frame.open();
return;
}
// Create the media frame.
file_frame = wp.media.frames.file_frame = wp.media({
title: 'My frame title',
button: {
text: 'My button text',
},
id: 'logo-frame',
multiple: false,
editing_sidebar: false, // Just added for example
default_tab: 'upload', // Just added for example
tabs: 'upload, library', // Just added for example
returned_image_size: 'thumbnail' // Just added for example
});
// When an image is selected, run a callback.
file_frame.on('select', function() {
var attachment;
// We set multiple to false so only get one image from the uploader
attachment = file_frame.state().get('selection').first().toJSON();
// Do something with attachment.id and/or attachment.url here
});
// Finally, open the modal
file_frame.open();
return false
});
嗨,你會知道爲什麼這行不起作用?作者:userSettings.uid - 畫廊不斷顯示所有照片。謝謝! – jinggoy