ap_get_category_image( integer $term_id, integer $height = 32 )

Description #

Return category image.

Parameters #

  • $term_id
    integer (Required) Category ID.
  • $height
    integer (Optional) image height, without PX. Default value: 32

Source #

File: includes/taxo.php

function ap_get_category_image( $term_id, $height = 32 ) {
	$option = get_term_meta( $term_id, 'ap_category', true );
	$color  = ! empty( $option['color'] ) ? ' background:' . $option['color'] . ';' : 'background:#333;';

	$style = 'style="' . $color . 'height:' . $height . 'px;"';

	if ( ! empty( $option['image']['id'] ) ) {
		$image = wp_get_attachment_image( $option['image']['id'], array( 900, $height ) );
		return $image;
	}

	return '<div class="ap-category-defimage" ' . $style . '></div>';
}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment