Restricting Image Upload Sizes using ‘wp_handle_upload_prefilter’ – Stuck media progress bar when Featured Image?

Try using JavaScript to handle this situation. The script should run when a user attempts to upload an image, and if the image upload fails, it will remove the associated UI elements (including that stubborn loading bar). Here’s a quick code:

jQuery(document).ready(function($) {
    wp.Uploader.prototype.init = function() {
        this.uploader.bind('BeforeUpload', function(uploader, file) {
            uploader.settings.multipart_params = {
                ...uploader.settings.multipart_params,
                file_id: file.id
            };
        });
    };

    wp.media.controller.Library.prototype.activate = function() {
        var library = this.get('library');
        library.on('remove', function(attachment) {
            var file = jQuery('#media-attachment-upload-progress-' + attachment.attributes.uploading.id).closest('.media-modal-icon');
            if (file.length > 0) {
                file.remove();
            }
        }, this);
        return wp.media.controller.State.prototype.activate.apply(this, arguments);
    };
});

I haven’t tested this, just give that a try and adjust accordingly.

techhipbettruvabetnorabahisbahis forumutaraftarium24eduseduedueduseduedueduseduedusedus