I asked chatgpt another way.
He provided me with this code which works, but I have to use {echo:brx_get_brand_archive_image_id}
> <?php
> /**
> * Retourne l'ID de l'image d'archive de la marque WooCommerce.
> *
> * - Sur une archive de marque (taxonomy product_brand) : prend la marque courante.
> * - Sur un produit : prend la première marque associée au produit.
> *
> * Taxonomy utilisée : product_brand (WooCommerce Brands / WooCommerce 9.6+).
> * Si ta taxonomy a un autre slug, change 'product_brand' ci-dessous.
> */
> if ( ! function_exists( 'brx_get_brand_archive_image_id' ) ) {
> function brx_get_brand_archive_image_id() {
> $taxonomy = 'product_brand'; // À adapter si besoin (ex: 'pa_brand')
> $term = null;
> // 1) Cas : page d'archive de marque
> if ( is_tax( $taxonomy ) ) {
> $term = get_queried_object();
> }
> // 2) Cas : page produit ou boucle produit
> if ( ! $term ) {
> $post_id = get_the_ID();
> if ( ! $post_id ) {
> return '';
> }
> $terms = get_the_terms( $post_id, $taxonomy );
> if ( empty( $terms ) || is_wp_error( $terms ) ) {
> return '';
> }
> // On prend la première marque trouvée
> $term = array_shift( $terms );
> }
> if ( ! $term || empty( $term->term_id ) ) {
> return '';
> }
> // WooCommerce Brands stocke le logo dans la meta 'thumbnail_id'
> $thumb_id = get_term_meta( $term->term_id, 'thumbnail_id', true );
> if ( ! $thumb_id ) {
> return '';
> }
> // IMPORTANT : on retourne l'ID de l'image (Bricks sait le gérer en contexte "image")
> return (int) $thumb_id;
> }
> }
> /**
> * Autoriser la fonction pour le tag {echo:...} de Bricks (Bricks 1.9.7+)
> */
> add_filter( 'bricks/code/echo_function_names', function( $functions ) {
> if ( ! is_array( $functions ) ) {
> $functions = [];
> }
> $functions[] = 'brx_get_brand_archive_image_id';
> return $functions;
> } );
It would be interesting to be able to display images from the “brand” archive natively in Bricks using dynamic data.