File "utils.ts"
Full Path: /home/warrior1/public_html/plugins/woocommerce/packages/woocommerce-blocks/assets/js/blocks/featured-items/featured-category/utils.ts
File size: 653 bytes
MIME-type: text/x-java
Charset: utf-8
/**
* External dependencies
*/
import { WP_REST_API_Category } from 'wp-types';
/**
* Internal dependencies
*/
import { isImageObject } from '../types';
/**
* Get the src from a category object, unless null (no image).
*/
export function getCategoryImageSrc( category: WP_REST_API_Category ) {
if ( category && isImageObject( category.image ) ) {
return category.image.src;
}
return '';
}
/**
* Get the attachment ID from a category object, unless null (no image).
*/
export function getCategoryImageId( category: WP_REST_API_Category ) {
if ( category && isImageObject( category.image ) ) {
return category.image.id;
}
return 0;
}