[wp-hackers] Wordpress Media Uploader Use in a Plugin

BenderisGreat greglancaster71 at gmail.com
Mon Jul 7 21:18:27 UTC 2014

I am having some trouble using the Media Library in a plugin.  I have a meta
box in the new post area, and it allows for selection of a picture. The
issue is I dont see how to allow selection of more than one image, but more
importantly the image is returned at full size.  The attachment var returns
only the full size.  I am using this jQuery :

      var custom_uploader;
    $('#upload_image_button').click(function(e) {
          //If the uploader object has already been created, reopen the
          if (custom_uploader) {
          //Extend the wp.media object
          custom_uploader = wp.media({
              title: 'Choose Image',
              button: {
                  text: 'Choose Image',
              multiple: false,
             // If you pretent a function only for images you can limit the
media elements only to images
             library : { type : 'image' }

         //When close, grab the url of the image where needed
        custom_uploader.on('close', function() {
            attachment =
            console.log(attachment); ## This only returns the full size url,
no thumbnails.
            $('.custom_preview_image').attr("src", attachment.url);

       //Open the uploader dialog

    $('#clear_images').click(function() {  
        var defaultImage =
        $('img.custom_preview_image').attr('src', '');
        return false;  

Is there something I am doing wrong?  Or is returning the full size media
file the only available option?  (I followed most of this tutorial to get
where I am guys --

View this message in context: http://wordpress-hackers.1065353.n5.nabble.com/Wordpress-Media-Uploader-Use-in-a-Plugin-tp44096.html
Sent from the Wordpress Hackers mailing list archive at Nabble.com.

More information about the wp-hackers mailing list