From e2687de98420c46d3ff99f82830bfcf1d3fb27ef Mon Sep 17 00:00:00 2001 From: Intenzi Date: Tue, 5 May 2026 19:17:36 +0530 Subject: [PATCH 1/3] Media: prevent non-image upload error for Site Icon --- src/js/_enqueues/admin/site-icon.js | 5 +++++ src/js/_enqueues/wp/customize/controls.js | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/js/_enqueues/admin/site-icon.js b/src/js/_enqueues/admin/site-icon.js index a658f16e0b61a..49c6504156b59 100644 --- a/src/js/_enqueues/admin/site-icon.js +++ b/src/js/_enqueues/admin/site-icon.js @@ -117,6 +117,11 @@ // Grab the selected attachment. var attachment = frame.state().get( 'selection' ).first(); + if ( 'image' !== attachment.attributes.type ) { + window.alert( wp.i18n.__( 'The uploaded file is not a valid image. Please select a valid file format.' ) ); + return; + } + if ( attachment.attributes.height === $el.data( 'size' ) && $el.data( 'size' ) === attachment.attributes.width diff --git a/src/js/_enqueues/wp/customize/controls.js b/src/js/_enqueues/wp/customize/controls.js index 921983e6bf78d..60712aff3c539 100644 --- a/src/js/_enqueues/wp/customize/controls.js +++ b/src/js/_enqueues/wp/customize/controls.js @@ -4791,6 +4791,11 @@ var attachment = this.frame.state().get( 'selection' ).first().toJSON(), controller = this; + if ( 'image' !== attachment.type ) { + window.alert( wp.i18n.__( 'The uploaded file is not a valid image. Please select a valid file format.' ) ); + return; + } + if ( this.params.width === attachment.width && this.params.height === attachment.height && ! this.params.flex_width && ! this.params.flex_height ) { wp.ajax.post( 'crop-image', { nonce: attachment.nonces.edit, From d25ca7f153ec4c31fbb98fdc7daa8c6ee8214388 Mon Sep 17 00:00:00 2001 From: Intenzi Date: Tue, 5 May 2026 19:18:28 +0530 Subject: [PATCH 2/3] Media: prevent non-image upload error for Site Logo --- src/js/_enqueues/wp/customize/controls.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/js/_enqueues/wp/customize/controls.js b/src/js/_enqueues/wp/customize/controls.js index 60712aff3c539..e7a9a81902d8f 100644 --- a/src/js/_enqueues/wp/customize/controls.js +++ b/src/js/_enqueues/wp/customize/controls.js @@ -4571,6 +4571,11 @@ onSelect: function() { var attachment = this.frame.state().get( 'selection' ).first().toJSON(); + if ( 'image' !== attachment.type ) { + window.alert( wp.i18n.__( 'The uploaded file is not a valid image. Please select a valid file format.' ) ); + return; + } + if ( this.params.width === attachment.width && this.params.height === attachment.height && ! this.params.flex_width && ! this.params.flex_height ) { this.setImageFromAttachment( attachment ); this.frame.close(); From 7846b2abc3348acf7a8b0be3849d2adcfda0cff6 Mon Sep 17 00:00:00 2001 From: Intenzi Date: Tue, 5 May 2026 19:18:45 +0530 Subject: [PATCH 3/3] Media: prevent non-image upload error for Header Image --- src/js/_enqueues/wp/customize/controls.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/js/_enqueues/wp/customize/controls.js b/src/js/_enqueues/wp/customize/controls.js index e7a9a81902d8f..f8ed7d6b666da 100644 --- a/src/js/_enqueues/wp/customize/controls.js +++ b/src/js/_enqueues/wp/customize/controls.js @@ -5070,6 +5070,13 @@ * switch to the cropper state. */ onSelect: function() { + var attachment = this.frame.state().get( 'selection' ).first().toJSON(); + + if ( 'image' !== attachment.type ) { + window.alert( wp.i18n.__( 'The uploaded file is not a valid image. Please select a valid file format.' ) ); + return; + } + this.frame.setState('cropper'); },