Last active
January 4, 2016 14:07
-
-
Save donaldG/5f29bc8035b96d4034a1 to your computer and use it in GitHub Desktop.
a little function to display credit for woocommerce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function woocommerce_subcategory_thumbnail( $category ) { | |
$small_thumbnail_size = apply_filters( 'single_product_small_thumbnail_size', 'shop_catalog' ); | |
$dimensions = wc_get_image_size( $small_thumbnail_size ); | |
$thumbnail_id = get_woocommerce_term_meta( $category->term_id, 'thumbnail_id', true ); | |
if ( $thumbnail_id ) { | |
$image = wp_get_attachment_image_src( $thumbnail_id, $small_thumbnail_size ); | |
$image = $image[0]; | |
} else { | |
$image = wc_placeholder_img_src(); | |
} | |
if ( $image ) { | |
// Prevent esc_url from breaking spaces in urls for image embeds | |
// Ref: http://core.trac.wordpress.org/ticket/23605 | |
$image = str_replace( ' ', '%20', $image ); | |
echo '<img src="' . esc_url( $image ) . '" alt="' . esc_attr( $category->name ) . '" width="' . esc_attr( $dimensions['width'] ) . '" height="' . esc_attr( $dimensions['height'] ) . '" /><span class="acf-media-credit">'.the_media_credit_html($thumbnail_id).'</span>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment