Server IP : 104.21.14.103 / Your IP : 18.116.63.105 Web Server : LiteSpeed System : Linux business53.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : giankuin ( 1871) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/giankuin/www/wp-content/plugins/woocommerce/packages/woocommerce-blocks/assets/js/utils/ |
Upload File : |
/** * Get the src of the first image attached to a product (the featured image). * * @param {Object} product The product object to get the images from. * @param {Array} product.images The array of images, destructured from the product object. * @return {string} The full URL to the image. */ export function getImageSrcFromProduct( product ) { if ( ! product || ! product.images || ! product.images.length ) { return ''; } return product.images[ 0 ].src || ''; } /** * Get the ID of the first image attached to a product (the featured image). * * @param {Object} product The product object to get the images from. * @param {Array} product.images The array of images, destructured from the product object. * @return {number} The ID of the image. */ export function getImageIdFromProduct( product ) { if ( ! product || ! product.images || ! product.images.length ) { return 0; } return product.images[ 0 ].id || 0; }