Commit 2e4602fc7b for woocommerce
commit 2e4602fc7b723fcda1db6c3ea9607c8f9b242526
Author: Marin Atanasov <8436925+tyxla@users.noreply.github.com>
Date: Tue Dec 9 14:25:02 2025 +0200
Brands: Clear thumbnail after creating a brand (#62333)
* Brands: Clear thumbnail after creating a brand
* Add changefile(s) from automation for the following project(s): woocommerce
* Remove cleanup duplication
---------
Co-authored-by: github-actions <github-actions@github.com>
diff --git a/plugins/woocommerce/changelog/62333-fix-brands-clear-thumbnail-after-creation b/plugins/woocommerce/changelog/62333-fix-brands-clear-thumbnail-after-creation
new file mode 100644
index 0000000000..63f89fb08b
--- /dev/null
+++ b/plugins/woocommerce/changelog/62333-fix-brands-clear-thumbnail-after-creation
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+Comment: Brands: Clear thumbnail after creating a brand
+
diff --git a/plugins/woocommerce/includes/admin/class-wc-admin-brands.php b/plugins/woocommerce/includes/admin/class-wc-admin-brands.php
index f847fbf01b..b49229f44d 100644
--- a/plugins/woocommerce/includes/admin/class-wc-admin-brands.php
+++ b/plugins/woocommerce/includes/admin/class-wc-admin-brands.php
@@ -332,6 +332,12 @@ class WC_Brands_Admin {
// Uploading files
var file_frame;
+ function clearThumbnailField() {
+ jQuery('#product_cat_thumbnail img').attr('src', '<?php echo esc_js( wc_placeholder_img_src() ); ?>');
+ jQuery('#product_cat_thumbnail_id').val('');
+ jQuery('.remove_image_button').hide();
+ }
+
jQuery(document).on( 'click', '.upload_image_button', function( event ){
event.preventDefault();
@@ -365,11 +371,24 @@ class WC_Brands_Admin {
});
jQuery(document).on( 'click', '.remove_image_button', function( event ){
- jQuery('#product_cat_thumbnail img').attr('src', '<?php echo esc_js( wc_placeholder_img_src() ); ?>');
- jQuery('#product_cat_thumbnail_id').val('');
- jQuery('.remove_image_button').hide();
+ clearThumbnailField();
return false;
});
+
+ jQuery( document ).on( 'ajaxComplete', function( event, request, options ) {
+ if ( request && 4 === request.readyState && 200 === request.status
+ && options.data && 0 <= options.data.indexOf( 'action=add-tag' ) ) {
+
+ var res = wpAjax.parseAjaxResponse( request.responseXML, 'ajax-response' );
+ if ( ! res || res.errors ) {
+ return;
+ }
+
+ clearThumbnailField();
+
+ return;
+ }
+ } );
});
</script>