Skip to content

Commit

Permalink
added support for WooCommerce v3.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
dharmeshtatva committed Feb 27, 2018
1 parent 6bc2005 commit cc4564e
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions includes/class-featured-image-by-url-common.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ function knawatfibu_overwrite_thumbnail_with_url( $html, $post_id, $post_image_i
return $html;
}

if( is_singular( 'product' ) && 'product' == get_post_type( $post_id ) && 'shop_single' == $size ){

if( is_singular( 'product' ) && 'product' == get_post_type( $post_id ) ){
return $html;
}

Expand Down Expand Up @@ -302,9 +301,11 @@ function knawatfibu_replace_attachment_image_src( $image, $attachment_id, $size,
$url = $knawatfibu->common->knawatfibu_resize_image_on_the_fly( $url, $size );
}
$image_size = $knawatfibu->common->knawatfibu_get_image_size( $size );

if ($url) {
if ($url) {
if( $image_size ){
if( !isset( $image_size['crop'] ) ){
$image_size['crop'] = '';
}
return array(
$url,
$image_size['width'],
Expand All @@ -324,7 +325,7 @@ function knawatfibu_replace_attachment_image_src( $image, $attachment_id, $size,
}
}

if( false !== strpos( $attachment_id, '_knawatfibu_fimage_url' ) && in_array( $size, array( 'shop_thumbnail', 'shop_single', 'full' ) ) ){
if( false !== strpos( $attachment_id, '_knawatfibu_fimage_url' ) ){
$attachment = explode( '__', $attachment_id );
$product_id = $attachment[1];
if( $product_id > 0 ){
Expand All @@ -343,9 +344,11 @@ function knawatfibu_replace_attachment_image_src( $image, $attachment_id, $size,
}

$image_size = $knawatfibu->common->knawatfibu_get_image_size( $size );

if ($image_url) {
if ($image_url) {
if( $image_size ){
if( !isset( $image_size['crop'] ) ){
$image_size['crop'] = '';
}
return array(
$image_url,
$image_size['width'],
Expand Down Expand Up @@ -376,6 +379,12 @@ function knawatfibu_replace_attachment_image_src( $image, $attachment_id, $size,
function knawatfibu_get_image_size( $size ) {
$sizes = $this->knawatfibu_get_image_sizes();

if( is_array( $size ) ){
$woo_size = array();
$woo_size['width'] = $size[0];
$woo_size['height'] = $size[1];
return $woo_size;
}
if ( isset( $sizes[ $size ] ) ) {
return $sizes[ $size ];
}
Expand Down

0 comments on commit cc4564e

Please sign in to comment.