Woocommerce ottieni immagine categoria a dimensione piena
30 ago 2015, 20:43:30
Visualizzazioni: 30.2K
Voti: 7
Sto cercando di ottenere l'immagine a dimensione piena delle mie categorie prodotti.
$prod_categories = get_terms( 'product_cat', array(
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => true
));
foreach( $prod_categories as $prod_cat ) :
$cat_thumb_id = get_woocommerce_term_meta( $prod_cat->term_id, 'thumbnail_id', true );
$cat_thumb_url = wp_get_attachment_thumb_url( $cat_thumb_id );
$term_link = get_term_link( $prod_cat, 'product_cat' );?>
<a href="<?php echo $term_link; ?>"><img src="<?php echo $cat_thumb_url; ?>" alt="<?php echo $prod_cat->name; ?>" /></a>
<?php endforeach; wp_reset_query();
Il codice sopra funziona, ma restituisce un'immagine di 150px x 150px anche quando le impostazioni in Woocommerce sono come queste:
Vorrei ottenere una dimensione più grande o la dimensione piena. Grazie!

Sema Hernández
161
Tutte le risposte alla domanda
1
1
Grazie a Mike Jolley (autore del plugin Woocommerce) per la soluzione che utilizza: wp_get_attachment_image_src
$prod_categories = get_terms( 'product_cat', array(
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => true
));
foreach( $prod_categories as $prod_cat ) :
$cat_thumb_id = get_woocommerce_term_meta( $prod_cat->term_id, 'thumbnail_id', true );
$shop_catalog_img = wp_get_attachment_image_src( $cat_thumb_id, 'shop_catalog' );
$term_link = get_term_link( $prod_cat, 'product_cat' );?>
<a href="<?php echo $term_link; ?>"><img src="<?php echo $shop_catalog_img[0]; ?>" alt="<?php echo $prod_cat->name; ?>" title="Immagine categoria <?php echo $prod_cat->name; ?>" /></a>
<?php endforeach; wp_reset_query();

Sema Hernández
161
1 set 2015 19:11:58
Domande correlate
2
risposte
5
risposte
5
risposte
4
risposte