WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 5 months ago

#36722 new defect (bug)

No way to access media "Attachment Display Settings" using wp.media

Reported by: chattyboy Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.5.1
Component: General Keywords:
Focuses: javascript Cc:
PR Number:

Description

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.

Change History (0)

Note: See TracTickets for help on using tickets.