jtsternberg / Shortcode_Button

Tinymce and Quicktag buttons for outputting shortcodes. Built to work with CMB2.
81 stars 7 forks source link

Shortcode attributes when using file and file_list field types #16

Open mralessio opened 7 years ago

mralessio commented 7 years ago

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" /] ?

jtsternberg commented 7 years ago

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

mralessio commented 7 years ago

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.

jtsternberg commented 7 years ago

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

mralessio commented 7 years ago

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