Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wp.media multiple:true setting isnt working in custom plugin

I'm using the wordpress media library in my plugin...

var images = wp.media({
            title: 'Upload Images',
            library: {type: 'image'},
            multiple: true
        }).open().on('select', function(e){...});

... but multiple:true is not working. I found a post the other day where someone listed an option other than 'true' that made the selection of multiple images work in my plugin. I didn't think I'd need it then but now I do and after days of searching I still can not find this post again.

If anyone could please point me to this post or tell me what value to use to make this work with the newest version of wordpress I would greatly appreciate it.

I know the codex and a ton of posts say the value should be true but this doesnt work and I know something else will because I did it the other day in testing.

like image 295
Vel Avatar asked Apr 01 '18 02:04

Vel


People also ask

Why is the ‘add media’ button not working in WordPress?

This is usually done in the WordPress admin area to improve performance and speed. The WordPress post editor uses JavaScript for all buttons on the screen including the add media button. A conflict can stop JavaScript from working which will disable the ‘Add Media’ button.

How to fix ‘add media’ button not working on staging site?

On your staging site, you need to start by deactivating all your WordPress plugins and then check if it fixed the ‘Add Media’ button. If it does, then this means one of the plugins was causing the issue. You can now activate the plugins one-by-one, and after activating a plugin check the ‘Add Media’ button.

How to add a custom plugin option group in WordPress?

1.Open “options.php” file (File Location: wp\wp-admin\options.php). 2.Add the custom plugin option group in the $whitelist_options array. ? You can download the sample code here. After reading this document you will be able to add the setting of your custom plugin in the WordPress setting menu.

Why are my WordPress themes not working?

A lot of WordPress themes these days make use of java-script/jQuery to enhance the themes adding things such as image sliders, toggles, accordions, tabs, mobile menus, image hovers…etc. If the these features are not working on your theme or suddenly stopped working its most likely do to some sort of javascript error causing everything to break.


2 Answers

@#$%#, remembered it as soon as I left this post!

It's multiple: 'add' if anyone needs to know.

And if anyone finds the post give them credit!

like image 149
Vel Avatar answered Oct 18 '22 01:10

Vel


For the sake of completness:

multiple: true works and allows the user to select multiple images BUT the user has to press CTRL key while selecting files if he wants to select more than one.

multiple: 'add' works and allows the user to select multiple images WITHOUT requiring the user to press the CTRL key.

like image 5
Tristan CHARBONNIER Avatar answered Oct 18 '22 00:10

Tristan CHARBONNIER