1

I need a way to add images/gallery to a model created by the WP MVC plugin(which is pretty awesome) for wordpress. It would be nice to tie in the new functionality offered in 3.5 but I really don't know where to start with this.

I tried a few google searches but I could not find anything pertaining to my needs.

Thank you for any assistance.

Custom Model Lawyers

styks
  • 3,193
  • 1
  • 23
  • 36

4 Answers4

3

I also got the error "wpActiveEditor is not defined" while trying to use media dialog on my custom page. As I saw, script tries to use property window.wpActiveEditor that is not defined. So the solution is to define the property

window.wpActiveEditor = null;
nhahtdh
  • 55,989
  • 15
  • 126
  • 162
2

This problem happens when you do the following:

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

If you pass $(this) as a first parameter to this open(), the problem will be solved:

$(selector).click(function(){
    // ...
    // initialization code
    // ...
    exports.media.editor.open($(this));
});
Denis V
  • 3,290
  • 1
  • 28
  • 40
0

maybe it's something to help

https://gist.github.com/4283059

https://wordpress.stackexchange.com/questions/75808/using-wordpress-3-5-media-uploader-in-meta-box

Community
  • 1
  • 1
Kaiser
  • 748
  • 7
  • 21
0

You can use the WP function wp_handle_upload something like this in your 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']);
    }
}
Marcelo Rodovalho
  • 880
  • 1
  • 15
  • 26