diff -ruN pa/nolanizreal-site/nolanizreal-site.php pb/nolanizreal-site/nolanizreal-site.php --- pa/nolanizreal-site/nolanizreal-site.php 2026-09-25 10:35:16 +++ pb/nolanizreal-site/nolanizreal-site.php 2026-09-25 10:35:16 @@ -2,7 +2,7 @@ /** * Plugin Name: Nolan Izreal — Site * Description: Briques dynamiques du site nolanizreal.art que le builder ne fournit pas en natif : sélecteur de langue accessible et lien panier traduit. Aucune mise en forme ici — le design reste dans Oxygen. - * Version: 1.0.2 + * Version: 1.0.3 * Author: Gérald Morales */ @@ -681,6 +681,34 @@ // Vignettes non recadrées : une affiche ne se rogne pas, même en miniature. add_filter( 'woocommerce_gallery_thumbnail_size', function () { return 'medium'; } ); add_filter( 'woocommerce_gallery_image_size', function () { return 'large'; } ); + +/** + * Panier et commande : la miniature est l'affiche (image à la une de l'œuvre), pas la mise en situation + * de la variation, et en taille « medium » (non recadrée) pour ne pas rogner l'affiche. + */ +function ni_image_affiche_panier( $cart_item ) { + $pid = ! empty( $cart_item['product_id'] ) ? (int) $cart_item['product_id'] : 0; + return $pid ? (int) get_post_thumbnail_id( $pid ) : 0; +} +add_filter( 'woocommerce_store_api_cart_item_images', function ( $images, $cart_item ) { + $id = ni_image_affiche_panier( $cart_item ); + $src = $id ? wp_get_attachment_image_src( $id, 'full' ) : false; + $mini = $id ? wp_get_attachment_image_src( $id, 'medium' ) : false; + if ( ! $src || ! $mini ) { return $images; } + return array( (object) array( + 'id' => $id, + 'src' => $src[0], + 'thumbnail' => $mini[0], + 'srcset' => (string) wp_get_attachment_image_srcset( $id, 'full' ), + 'sizes' => (string) wp_get_attachment_image_sizes( $id, 'full' ), + 'name' => get_the_title( $id ), + 'alt' => (string) get_post_meta( $id, '_wp_attachment_image_alt', true ), + ) ); +}, 10, 2 ); +add_filter( 'woocommerce_cart_item_thumbnail', function ( $html, $cart_item ) { + $id = ni_image_affiche_panier( $cart_item ); + return $id ? wp_get_attachment_image( $id, 'medium' ) : $html; +}, 10, 2 ); /** Galerie native WooCommerce : image principale + vues rattachées (sans zoom ni visionneuse). */ add_shortcode( 'ni_galerie_oeuvre', function () {