esc_js( __( 'Sélectionner une image de catégorie', 'category-grid-widget' ) ), 'button' => esc_js( __( 'Sélectionner', 'category-grid-widget' ) ), ] ); } add_action( 'admin_enqueue_scripts', 'ccgw_enqueue_media_uploader' ); // 1) Déclarez la colonne "Image" dans le tableau des catégories add_filter( 'manage_edit-category_columns', function( $columns ) { $new = []; foreach ( $columns as $key => $label ) { $new[ $key ] = $label; if ( 'name' === $key ) { // après la colonne "Nom", on insère notre colonne "Image" $new['category_image'] = esc_html__( 'Image', 'category-grid-widget' ); } } return $new; } ); // 2) Remplissez la colonne "Image" add_filter( 'manage_category_custom_column', function( $out, $column, $term_id ) { if ( 'category_image' === $column ) { $thumb_id = get_term_meta( $term_id, 'thumbnail_id', true ); if ( $thumb_id ) { // Affiche la version 'thumbnail' de l'image return wp_get_attachment_image( $thumb_id, 'thumbnail', false, [ 'style' => 'max-width:60px;height:auto;' ] ); } } return $out; }, 10, 3 ); // 3) Un peu de CSS pour la largeur de colonne et la mise en forme add_action( 'admin_head-edit-tags.php', function() { echo ''; } ); /** * Affiche le champ d'upload dans le formulaire de création de catégorie. */ function ccgw_category_image_field( $taxonomy ) { ?>