Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

141
Views
How hide Variations featured image from the WooCommerce gallery?

How can I hide the featured image of any product variety from the gallery? The products on my website are in "Variations" and the codes I saw are for "simple products". I use (alt = "MainImage") for featured images, but the following jQuery code did not work either.

enter image description here

$('[alt="MainImage"]').hide();
$('[alt="MainImage"]').parent().hide();
$('[alt="MainImage"]').css( "display", "none" );
$('div[data-thumb-alt="MainImage"]').hide();
$('img[alt="MainImage"]').css( "display", "none" );
$('img[data-thumb-alt="MainImage"]').hide();
$('div[title="Tajkan_0101"]').hide();
// :|
<img width="234" height="400" src="https://.../wp-content/uploads/2021/09/Tajkan_0101.jpg" class="" alt="MainImage" loading="lazy" title="Tajkan_0101" data-caption="" data-src="https://.../wp-content/uploads/2021/09/Tajkan_0101.jpg" data-large_image="https://.../wp-content/uploads/2021/09/Tajkan_0101.jpg" data-large_image_width="234" data-large_image_height="400" srcset="https://.../wp-content/uploads/2021/09/Tajkan_0101.jpg 234w, https://.../wp-content/uploads/2021/09/Tajkan_0101-176x300.jpg 176w" sizes="(max-width: 234px) 100vw, 234px" draggable="false">

Unfortunately, this code is only for simple products:

add_filter('woocommerce_single_product_image_thumbnail_html', 'remove_featured_image', 10, 2);
function remove_featured_image($html, $attachment_id ) {
global $post, $product;

$featured_image = get_post_thumbnail_id( $post->ID );

if ( $attachment_id == $featured_image )
    $html = '';

return $html;
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!