2012-12-14 70 views
0

我需要一種方法將圖片/圖庫添加到由WP MVC插件創建的模型(這非常棒)。這將是很好的綁定在3.5提供的新功能,但我真的不知道從哪裏開始。Wordpress和WP MVC上傳圖片

我嘗試了一些谷歌搜索,但我找不到任何有關我的需求。

感謝您的協助。

Custom Model Lawyers

+1

Look http://stackoverflow.com/questions/13847714/wordpress-3-5-custom-media-upload-for-your-theme-options – Kaiser

+0

這看起來很有前途的感謝。 – styks

+0

我不斷收到@wpActiveEditor沒有定義@。我認爲這與tinyMCE有關? – styks

回答

2

我也得到了錯誤 「wpActiveEditor沒有定義」 試圖到我的自定義頁面上使用的媒體對話。正如我所看到的,腳本嘗試使用未定義的屬性window.wpActiveEditor。所以,解決的辦法是定義屬性

window.wpActiveEditor = null; 
0

可以使用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']); 
    } 
} 
2

發生此問題,當你做到以下幾點:

$(selector).click(function(){ 
    // ... 
    // initialization code 
    // ... 
    exports.media.editor.open(); 
}); 

如果您將$(this)作爲第一個參數傳遞給open(),則問題將被解決:

$(selector).click(function(){ 
    // ... 
    // initialization code 
    // ... 
    exports.media.editor.open($(this)); 
});