How to upload multiple images on frontend to ACF gallery using update_field
Argh..easy to fix: instead of include( ABSPATH . ‘wp-admin/includes/image.php’ ); use require_once( ABSPATH . ‘wp-admin/includes/image.php’ ); Hope this helps someone!
Argh..easy to fix: instead of include( ABSPATH . ‘wp-admin/includes/image.php’ ); use require_once( ABSPATH . ‘wp-admin/includes/image.php’ ); Hope this helps someone!
The hook for doing stuff after an upload is the reset event on wp.Uploader.queue triggered by the pluploader when it’s finished (see line 249 in “wp-includes/js/plupload/wp-plupload.js”). Here’s one hack to use this to do an auto-insert after an upload: function wpse167143_admin_footer() { ?> <script> jQuery( document ).ready(function() { typeof wp.Uploader !== ‘undefined’ && wp.Uploader.queue.on( ‘reset’, … Read more
All of the code in your question can be replaced with: require_once( ABSPATH . ‘wp-admin/includes/image.php’ ); require_once( ABSPATH . ‘wp-admin/includes/file.php’ ); require_once( ABSPATH . ‘wp-admin/includes/media.php’ ); if ( $_FILES ) { foreach ($_FILES as $file => $array) { $image_post_id = media_handler_upload( $file ); if ( is_wp_error( $image_post_id ) ) { $error .= $image_post_id->get_error_message(); } else … Read more
You should check for the special characters in url, sometimes url structures may contain special characters like space, &, ‘ . use str_repalce to replace known special characters or urlencode. media_sideload_image works properly with JPG as well so either url contains special characters. If you can access image through url there is not a permission … Read more
Silly mistake, my custom page was missing the <?php wp_footer(); ?>
I had 2 things wrong: I unregistered wordpress’s jquery without properly registering my own (I concatenated my scripts ) I didnt have wp_footer() in my theme. the wp_enqueue_media() function loads the scripts to the footer.
You can use remove_image_size() to remove previously registered image sizes. Ex : <?php remove_image_size(‘full-width-image-gallery’); ?> Note: Cannot be used on reserved image size names
Using my own code from here, i updated the logic to add the name of the image size instead of the suffix, try adding this to your functions.php file: add_filter(“wp_image_editors”, “my_wp_image_editors”); function my_wp_image_editors($editors) { array_unshift($editors, “WP_Image_Editor_Custom”); return $editors; } // Include the existing classes first in order to extend them. require_once ABSPATH . WPINC . … Read more
Allowing file types outside of WP’s defaults exposes your site to some security risks, and some hosts don’t allow certain filetypes. If your host allows these filetypes, you can use the following function in a plugin or a child theme: function wpse_file_uploads($mime_types){ // photoshop $mime_types[‘psd’] = ‘image/vnd.adobe.photoshop’; // illustrator $mime_types[‘ai’] = ‘application/postscript’; // indesign $mime_types[‘indd’] … Read more
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php [L] # If images not found on development site, load from production RewriteCond %{REQUEST_URI} ^/wp-content/uploads/[^\/]*/.*$ RewriteRule ^(.*)$ https://www.example.com/$1 [QSA,L] The problem here is that “If images not found on development site” then the request has already been rewritten to index.php by the preceding RewriteRule (WordPress front-controller), … Read more