我需要一種方法將圖片/圖庫添加到由WP MVC插件創建的模型(這非常棒)。這將是很好的綁定在3.5提供的新功能,但我真的不知道從哪裏開始。Wordpress和WP MVC上傳圖片
我嘗試了一些谷歌搜索,但我找不到任何有關我的需求。
感謝您的協助。
我需要一種方法將圖片/圖庫添加到由WP MVC插件創建的模型(這非常棒)。這將是很好的綁定在3.5提供的新功能,但我真的不知道從哪裏開始。Wordpress和WP MVC上傳圖片
我嘗試了一些谷歌搜索,但我找不到任何有關我的需求。
感謝您的協助。
也許它的東西,以幫助
https://gist.github.com/4283059
https://wordpress.stackexchange.com/questions/75808/using-wordpress-3-5-media-uploader-in-meta-box
您在評論欄中的鏈接對我的幫助最大。謝謝! – styks
我也得到了錯誤 「wpActiveEditor沒有定義」 試圖到我的自定義頁面上使用的媒體對話。正如我所看到的,腳本嘗試使用未定義的屬性window.wpActiveEditor
。所以,解決的辦法是定義屬性
window.wpActiveEditor = null;
可以使用WP功能wp_handle_upload 這樣的事情在你的GalleriesController
function upload(){
if(!empty($this->params['data'])){
$overrides = array('test_form' => false);
$file = wp_handle_upload($_FILES['file'],$overrides);
$this->params['data']['Photo']['file'] = $file['url'];
$this->params['data']['Photo']['title'] = basename ($file['file']);
$this->Photo->save($this->params['data']);
}
}
發生此問題,當你做到以下幾點:
$(selector).click(function(){
// ...
// initialization code
// ...
exports.media.editor.open();
});
如果您將$(this)作爲第一個參數傳遞給open(),則問題將被解決:
$(selector).click(function(){
// ...
// initialization code
// ...
exports.media.editor.open($(this));
});
Look http://stackoverflow.com/questions/13847714/wordpress-3-5-custom-media-upload-for-your-theme-options – Kaiser
這看起來很有前途的感謝。 – styks
我不斷收到@wpActiveEditor沒有定義@。我認爲這與tinyMCE有關? – styks