Modify the array of selected images in media modal

I’m able to do the following in media modal: var selection =‘selection’); // get selected collection attachment =; // get attachment with id attachment.fetch(); selection.add(attachment); // add attachment to selection collection There should be .remove() method or something similar.

front end post with multiple upload images?

the multiple=”multiple” or multiple=”” attribute of input file tag is fairly new and not widely supported cross browser but if that is the way you want to go, try this: <form … <input type=”file” id=”image” name=”image[]” onchange=”updateList();” multiple=”multiple” > <ul id=”file_list”></ul> </form> <script> function updateList(){ //get the input and UL list var input = document.getElementById(‘image’); …

Read more

Convert uploaded PNG to JPEG automatically

There is a way, I recommend you combine the imagefx plugin with a custom function , You can read about it here: , and use a function like one found here: It would look something like (not tested): imagefx_register_filter(‘custom-name’,’my_custom_filter’); function my_custom_filter(&$image, $outputFile, $quality) { $image = imagecreatefrompng(&$image); imagejpeg($image, $outputFile, $quality); imagedestroy($image); } …

Read more

Using “media_handle_sideload” to upload images programmatically does not upload image to Media Library

Your failing and getting a WP_Error object returned before the function runs wp_insert_attachment(). You should always include a check for is_wp_error( $thing ) when calling a function that returns WP_Errors. $result = media_handle_sideload($array, $id); if ( ! is_wp_error( $result ) ) { return $result; } else { var_dump( $result->get_error_messages ); } Your problem will be …

Read more

How to set custom upload directory per user after moving content directory

With credits to petermolnar via irc:// I can answer my own question. The key is to set an upload-dir filter in the theme’s functions.php: function per_user_upload_dir( $original ){ // use the original array for initial setup $modified = $original; // set our own replacements if ( is_user_logged_in() ) { $current_user = wp_get_current_user(); $subdir = $current_user->user_login; …

Read more

Moving Media Library

There are three ways you could do this: 1. Upload all into the Media Library The most tiresome way, IMHO, is to upload all the images you got via the media library. 2. Use a plugin You can use plugins like Add From Server to import your images easily to the Media Library 3. WP-CLI …

Read more