Is it possible to use media_sideload_image to upload local files?

you can do this using the media_handle_upload() function. This is a working example that you can use as a guide for your requirements: First Create your HTML form <form method=”post” id=”uploadCartaAnno” enctype=”multipart/form-data”> <input class=”text-input” name=”carta_ano” type=”file” id=”carta_ano” multiple=”false”/> <?php wp_nonce_field( ‘my_image_upload’, ‘my_image_upload_nonce’ ); ?> <input name=”updatecarta_ano” type=”submit” id=”updatecarta_ano” class=”hp-btn-file -icon-upload” value=”Subir formato” /> <input name=”action” … Read more

using media_sideload_image with a file from theme directory

Please include the following files before using media_sideload_image() for it to work, require_once(ABSPATH . ‘wp-admin/includes/media.php’); require_once(ABSPATH . ‘wp-admin/includes/file.php’); require_once(ABSPATH . ‘wp-admin/includes/image.php’); Reference, WP Codex: media_sideload_image

Get File Object from wp.Uploader

You can’t hook it directly as wp.Uploader doesn’t expose it but you can use its init() to hook its internal pluploader instance: add_action( ‘admin_print_footer_scripts’, function () { ?> <script type=”text/javascript”> (function ($) { if (typeof wp.Uploader === ‘function’) { $.extend( wp.Uploader.prototype, { init : function() { // plupload ‘PostInit’ this.uploader.bind(‘BeforeUpload’, function(file) { console.log(‘BeforeUpload file=%o’, file); … Read more

Removal of Media Gallery pictures

If those images have been inserted in your posts, deleting them from the Media Library will cause blank spaces with a broken image icon to appear in your posts. If you need/want to add alt text or change image file names, etc., better to do so directly in the Media Library than to delete existing … Read more