( isset( $attributes['dimRatio'] ) && ( 0 !== $attributes['dimRatio'] ) ) { $classes[] = 'has-background-dim'; if ( 50 !== $attributes['dimRatio'] ) { $classes[] = 'has-background-dim-' . 10 * round( $attributes['dimRatio'] / 10 ); } } if ( isset( $attributes['contentAlign'] ) && 'center' !== $attributes['contentAlign'] ) { $classes[] = "has-{$attributes['contentAlign']}-content"; } if ( isset( $attributes['overlayColor'] ) ) { $classes[] = "has-{$attributes['overlayColor']}-background-color"; } if ( isset( $attributes['className'] ) ) { $classes[] = $attributes['className']; } return implode( ' ', $classes ); } /** * Returns the main product image URL. * * @param \WC_Product $product Product object. * @param string $size Image size, defaults to 'full'. * @return string */ public function get_image( $product, $size = 'full' ) { $image = ''; if ( $product->get_image_id() ) { $image = wp_get_attachment_image_url( $product->get_image_id(), $size ); } elseif ( $product->get_parent_id() ) { $parent_product = wc_get_product( $product->get_parent_id() ); if ( $parent_product ) { $image = wp_get_attachment_image_url( $parent_product->get_image_id(), $size ); } } return $image; } }