Unyson icon indicating copy to clipboard operation
Unyson copied to clipboard

How to add "Attachement Display Settings" options image size, alignment,... for media-image shorcode

Open Alex-Ascet opened this issue 11 years ago • 4 comments

Hi there,

How can I add "Attachement Display Settings" options image size, alignment,... for media-image shorcode? These options are displaying with the Default Editor when you click on the "Add media " button but not with the Image shortcode from the Visual Builder.... Where can I allow these options? Thank you so much for your help.

See attached. Default option from Wordpress: screen shot 2015-04-29 at 11 28 42 am

No option with the Image shortcode from the Visuel Builder: screen shot 2015-04-29 at 11 31 58 am

Alex-Ascet avatar Apr 29 '15 01:04 Alex-Ascet

@Alex-Ascet these is because our upload option type create an object from

wp.media({  
library: {
    type: 'image'
    }
})

this is an default wp.media frame named select, what you want is a frame called post but this post frame make sense when you work with WordPress editor, not when you upload an photo , because alignment and link have sense when the image is inserted in post, plus it trigger the changes in post editor, that is why we don't construct the upload frame as a post but we construct it as a select. If you want to see the difference , between these two media frames , please open an edit or add post page, open your browser devtool and in console insert these two lines

//Insert the first line and see the result 
wp.media({frame: 'select'}).open();
//Then insert the next line and see the result and difference between these two constructors
wp.media({frame: 'post'}).open();

We don't change this because we don't have the serious arguments when and why the user need this fields ,plus WordPress make these two different constructors with different behavior I think the guys behind WordPress knows what they do. If you have strong arguments why you need this , please give us an answer. If you agree our position , please close the issue. Thanks for the feedback.

llemurya avatar Apr 29 '15 08:04 llemurya

Hi llemurya, Thank you for your answer. I really appreciate. I would like to implement this option to avoid the "full" size image download and then resize only with the html "width" and "height" options. I mean, if the image is a 1024x768px and 3MB weight the browser will download this image then resize to 400px width (for exemple) but, with the same weight. I hope that makes sense. What do you think about this?

Alex-Ascet avatar Apr 29 '15 08:04 Alex-Ascet

@Alex-Ascet we already make resize of the image in media-image shortcode, please take a look at the proof.If this solution is not good you can use the WordPress default mecanism which consist in using of add_image_size function and using get_attachment_image function with $size parameter that you'll register. If it helps please close the issue. Thanks!

llemurya avatar Apr 29 '15 09:04 llemurya

Thank you very much for that and thank you for this framework! Well done. All the best.

Alex-Ascet avatar Apr 29 '15 10:04 Alex-Ascet