I have several thousand photos to add as "thumbnail". The products are already added to WooCommerce, but without the "thumnail". What do I have:
I want to change the default "thumbnail" to download from url. It works on FRONT, but I get an error in the admin when I go to the products tab "Call the get_attribute () member function on null"
function alterImageSRC($image, $attachment_id, $size, $icon){
global $product;
$koostis = $product->get_attribute( 'pa_featured-images' );
$image[0] = "https://link.com/wp-content/uploads/thumbs/'$koostis'";
return $image;
}
add_filter('wp_get_attachment_image_src', 'alterImageSRC', 10, 4);
I did it. I'm attaching a working code that generates a thumbnail based on an attribute. There is a link to the picture in the atrubucie of this product.
function alterImageSRC($image, $attachment_id, $size, $icon){
$product = wc_get_product();
$optimex_featured = $product->get_attribute( 'pa_featured-images' );
$image[0] = "https://link.com/wp-content/uploads/thumbs/'$optimex_featured'";
return $image;
}
add_filter('wp_get_attachment_image_src', 'alterImageSRC', 10, 4);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.