Shortcode_Button icon indicating copy to clipboard operation
Shortcode_Button copied to clipboard

Shortcode attributes when using file and file_list field types

Open mralessio opened this issue 8 years ago • 4 comments

When I use the file field type, I get the shortcode with id and id_id like: [inlayimage id="http://test.dev/wp-content/uploads/4618102_large.jpg" id_id="1017"][/inlayimage]

In case of file_list it puts it as an array: [inlayimages ids="{'1017':'http:\/\/test.dev\/wp-content\/uploads\/4618102_large.jpg','1010':'http:\/\/test.dev\/wp-content\/uploads\/posts\/60-very-interesting-post-lets-read-it\/cities_new_york.jpg'}" /]

Can I in any way have a plain shortcode markup like: [inlayimage id="image_ID"]caption[/inlayimage] and [inlayimages ids="image1_ID, image2_ID, image3_ID" /] ?

mralessio avatar Feb 26 '17 14:02 mralessio

Hmm not really. This library is a pretty opinionated one, so it would be difficult to change something like that (though probably not impossible).

jtsternberg avatar Feb 27 '17 15:02 jtsternberg

Finally I've managed to solve all things by extending Shortcode_Button class. So now I have all attributes appear in shortcode as I wished as well as textarea for the shortcode content.

Anyway thank you, Justin. Really appriciate your work over this library.

mralessio avatar Feb 28 '17 16:02 mralessio

Oh nice, that's a good way to handle it.

jtsternberg avatar Feb 28 '17 18:02 jtsternberg

One issue I've come across in case a file field. I test it also without any of my modifications. The same. If I select an attachment initially, the image is displayed as usually in a preview area (inside .cmb2-media-status). After inserting and then trying to edit the shortcode, the file field in modal appears already without the preview . Though it is populated with the image url and id correctly as I see it. The preview reloaded only after reselect the image.

image1

image2

mralessio avatar Feb 28 '17 21:02 mralessio