[wp-trac] [WordPress Trac] #36722: No way to access media "Attachment Display Settings" using wp.media

WordPress Trac noreply at wordpress.org
Fri Apr 29 15:55:49 UTC 2016


#36722: No way to access media "Attachment Display Settings" using wp.media
--------------------------+-----------------------------
 Reporter:  chattyboy     |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  4.5.1
 Severity:  normal        |   Keywords:
  Focuses:  javascript    |
--------------------------+-----------------------------
 I am using custom wp.media request to get WP Media uploader iframe on
 front end.

 Added scripts, styles and media:

 {{{
 wp_enqueue_script('jquery');
 wp_enqueue_media();
 wp_enqueue_style( 'wp-admin' );
 }}}

 then I am using JS to open the Media iframe:

 {{{
 var custom_uploader;
 jQuery(document).ready(function($){
         if (custom_uploader) {custom_uploader.open();return;}
         var parent_container = parent.document.body;

         custom_uploader = wp.media.frames.file_frame = wp.media({
                 frame: 'post',
                 state: 'insert',
                 title: 'Choose Image',
                 library : {type:'image'},
                 button: {text: 'Choose Image'},
                 multiple: false
         });

         custom_uploader.on('insert',function(){
                 var attachment =
 custom_uploader.state().get('selection').first().toJSON();

                 console.log( attachment );
         });

         custom_uploader.open();
 });
 }}}

 after selecting needed image, link and size I get the result:

 {{{
 {"id":2182,"title":"WordPress","filename":"WordPress.jpg","url":"http://localhost:8080/mgwebthemes.com/uploads/2015/05/WordPress.jpg","link":"http://localhost:8080/mgwebthemes.com/wordpress/","alt":"","author":"1","description":"","caption":"","name":"WordPress","status":"inherit","uploadedTo":2166,"date":"2015-05-13T09:09:47.000Z","modified":"2015-05-13T09:09:47.000Z","menuOrder":0,"mime":"image/jpeg","type":"image","subtype":"jpeg","icon":"http://localhost:8080/mgwebthemes.com
 /wp-
 includes/images/media/default.png","dateFormatted":"13/05/2015","nonces":{"update":"2d7619f512","delete":"725c6d8639","edit":"709844b592"},"editLink":"http://localhost:8080/mgwebthemes.com
 /wp-
 admin/post.php?post=2182&action=edit","meta":false,"authorName":"admin","uploadedToLink":"http://localhost:8080/mgwebthemes.com
 /wp-
 admin/post.php?post=2166&action=edit","uploadedToTitle":"Test","filesizeInBytes":8990,"filesizeHumanReadable":"9
 kB","sizes":{"thumbnail":{"height":150,"width":150,"url":"http://localhost:8080/mgwebthemes.com/uploads/2015/05
 /WordPress-
 150x150.jpg","orientation":"landscape"},"full":{"url":"http://localhost:8080/mgwebthemes.com/uploads/2015/05/WordPress.jpg","height":249,"width":201,"orientation":"portrait"}},"height":249,"width":201,"orientation":"portrait",...}
 }}}

 it does not contain any Attachment Display Settings options.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/36722>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list