Skip to content

Commit

Permalink
Added Shopz.io support #20
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdharmesh committed Jan 31, 2019
1 parent e45d0ce commit dee054a
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions includes/class-featured-image-by-url-common.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function __construct() {
add_filter( 'post_thumbnail_html', array( $this, 'knawatfibu_overwrite_thumbnail_with_url' ), 999, 5 );
add_filter( 'woocommerce_structured_data_product', array( $this, 'knawatfibu_woo_structured_data_product_support' ), 99, 2 );
add_filter( 'facebook_for_woocommerce_integration_prepare_product', array( $this, 'knawatfibu_facebook_for_woocommerce_support' ), 99, 2 );
add_filter( 'shopzio_product_image_from_id', array( $this, 'knawatfibu_shopzio_product_image_url' ), 10, 2 );

if( !is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ){
add_filter( 'wp_get_attachment_image_src', array( $this, 'knawatfibu_replace_attachment_image_src' ), 10, 4 );
Expand Down Expand Up @@ -506,4 +507,26 @@ public function knawatfibu_facebook_for_woocommerce_support( $product_data, $pro

return $product_data;
}

/**
* Add Support for Shopz.io WC GraphQL Support.
*
* @since 1.0
* @param array|string $image
* @param string $attachment_id
* @return altered Image.
*/
function knawatfibu_shopzio_product_image_url( $image, $attachment_id ) {
if( empty( $attachment_id ) || !empty($image)){
return $image;
}

$image_data = $this->knawatfibu_replace_attachment_image_src( $image, $attachment_id, 'full', false);
if (!empty($image_data) && isset($image_data[0]) && !empty($image_data[0])) {
$image = $image_data[0];
}

return $image;
}

}

0 comments on commit dee054a

Please sign in to comment.