任何人都可以幫助我爲基於「上傳」類型的NHP主題選項框架創建一個新的字段類型,以便它將使用WordPress自3.5以來使用的新「媒體管理器」,而不是媒體上傳器。這對使用滑塊非常有用。使用Wordpress 3.5媒體管理器的NHP主題選項框架
也許this post將會有所幫助。
任何人都可以幫助我爲基於「上傳」類型的NHP主題選項框架創建一個新的字段類型,以便它將使用WordPress自3.5以來使用的新「媒體管理器」,而不是媒體上傳器。這對使用滑塊非常有用。使用Wordpress 3.5媒體管理器的NHP主題選項框架
也許this post將會有所幫助。
FYI ... HTTP://reduxframework.com/是NHP的一個分支,並增加了3.5介質裝載器和NHP的也是固定的其他領域。
我剛剛切換到目前爲止還沒有壞。
你好運我需要這個相同的功能。我設法通過查看代碼並應用與舊媒體管理器相同的覆蓋技術來實現這一點。
其實我已經寫了一個關於它的教程here。
這裏的javascript代碼:
(function($){
var doc = {
ready: function(){
// initialize only if our button is in the page
if($('#btn_browse_files').length > 0){
slider.init();
}
}
},
slider = {
// the following 2 objects would be our backup containers
// as we will be replacing the default media handlers
media_send_attachment: null,
media_close_window: null,
init: function(){
// bind the button's click the browse_clicked handler
$('#btn_browse_files').click(slider.browse_clicked);
},
browse_clicked: function(event){
// cancel the event so we won't be navigated to href="#"
event.preventDefault();
// backup editor objects first
slider.media_send_attachment = wp.media.editor.send.attachment;
slider.media_close_window = wp.media.editor.remove;
// override the objects with our own
wp.media.editor.send.attachment = slider.media_accept;
wp.media.editor.remove = slider.media_close;
// open up the media manager window
wp.media.editor.open();
},
media_accept: function(props, attachment){
// this function is called when the media manager sends in media info
// when the user clicks the "Insert into Post" button
// this may be called multiple times (one for each selected file)
// you might be interested in the following:
// alert(attachment.id); // this stands for the id of the media attachment passed
// alert(attachment.url); // this is the url of the media attachment passed
// for now let's log it the console
// not you can do anything Javascript-ly possible here
console.log(props);
console.log(attachment);
},
media_close: function(id){
// this function is called when the media manager wants to close
// (either close button or after sending the selected items)
// restore editor objects from backup
wp.media.editor.send.attachment = slider.media_send_attachment;
wp.media.editor.remove = slider.media_close_window;
// nullify the backup objects to free up some memory
slider.media_send_attachment= null;
slider.media_close_window= null;
// trigger the actual remove
wp.media.editor.remove(id);
}
};
$(document).ready(doc.ready);
})(jQuery);
,請進入我們vafpress theme framework的GitHub代碼片段用法:
media manager with WP < 3.5 fallback
代碼,也有這個變量(vp_wp.use_new_media_upload
),你將需要通過wp_localize_script
爲「暴露」到您的JS代碼,該變量需要說明你正在運行的WordPress是否在3.5以下,如果它不到3.5,那麼它不應該使用新的媒體管理器,並使用舊的方法,使用厚盒子media-upload.php iframe。
NHP剛剛與Redux Framework合併,Redux 3.0已經發布。它可以作爲Wordpress插件運行或嵌入到主題中。你應該真的嘗試新版本。
http://wordpress.org/plugins/redux-framework/
它有完整的WordPress 3.5的媒體支持,然後一些。它不僅存儲媒體網址,還存儲ID和全維尺寸。
說真的,看看。