Make WordPress Core

Opened 8 years ago

Last modified 4 years ago

#36722 new defect (bug)

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

Reported by: chattyboy's profile chattyboy Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.5.1
Component: Media Keywords:
Focuses: javascript Cc:

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 (2)

This ticket was mentioned in Slack in #core by noisysocks. View the logs.


4 years ago

#2 @talldanwp
4 years ago

  • Component changed from General to Media

Hi @chattyboy, I realize some time has passed since you created this ticket. Apologies for the lack of a response in that time.

Is this an issue you're still experiencing, or did you manage to find a solution?

Note: See TracTickets for help on using tickets.