get_gallery_image_ids();
$image_size = tppif_image_size();
$image_srcset_sizes = tppif_image_srcset_sizes();
// Check the value of 'images_from_gallery_only' option
$images_from_gallery_only = get_option( 'images_from_gallery_only' );
$add_product_link_to_image = get_option( 'add_product_link_to_image' );
// If 'images_from_gallery_only' is checked, we take the first two images from the gallery
if ($images_from_gallery_only == 1 && count($get_gallery_image_ids) >= 2) {
$get_image_id = $get_gallery_image_ids[0];
$get_second_image_id = $get_gallery_image_ids[1];
} else {
$get_image_id = $product->get_image_id();
$get_second_image_id = isset($get_gallery_image_ids[0]) ? $get_gallery_image_ids[0] : null;
}
// Rest of your original function starts here...
$image_url_top = wp_get_attachment_image_url( $get_image_id, $image_size );
$image_url_top_srcset = wp_get_attachment_image_srcset( $get_image_id, $image_size );
$placeholder_img = wc_placeholder_img_src($image_size);
if($get_image_id){
$image_top_alt = get_post_meta($get_image_id, '_wp_attachment_image_alt', TRUE);
if(!$image_top_alt){
$image_top_alt = $product->get_name();
}
if($get_second_image_id){
$image_bottom_alt = get_post_meta($get_second_image_id, '_wp_attachment_image_alt', TRUE);
if(!$image_bottom_alt){
$image_bottom_alt = $image_top_alt;
}
$output = '
';
$image_url_bottom = wp_get_attachment_image_url( $get_second_image_id, $image_size );
$image_url_bottom_srcset = wp_get_attachment_image_srcset( $get_second_image_id, $image_size );
$output .= '
.')
';
$output .= '
.')
';
$output .= '
';
} else {
$output = '';
$output .= '
.')
';
$output .= '
';
}
} else {
$output = '';
$output .= '

';
$output .= '
';
}
if($add_product_link_to_image) {
echo ''.$output.'';
}
else {
echo $output;
}
}
function tppif_image_size() {
$default_size = 'woocommerce_thumbnail'; // 'thumbnail', 'medium', 'medium_large', 'large'
/**
* Filters the list of fliper image size.
*
* @since 1.0.6
*
* @param string[] $default_size An image size name. Defaults
* are 'woocommerce_thumbnail','thumbnail', 'medium', 'medium_large', 'large'.
*/
return apply_filters( 'tppif_image_size', $default_size );
}
function tppif_image_srcset_sizes() {
$default_sizes = '(max-width: 360px) 100vw, 360px';
/**
* Filters the list of fliper image size.
*
* @since 1.0.6
*
* @param string[] $default_size An image size name. Defaults
* are (max-width: 360px) 100vw, 360px.
*/
return apply_filters( 'tppif_image_srcset_sizes', $default_sizes );
}
add_action( 'wp_footer', 'tppif_script' );
function tppif_script() {
if(get_option( 'remove_duplicate_images' )) {
?>
' . __('Settings') . '';
$links[] = '' . __('Go Premium!') . '';
return $links;
}
//------------------------------------------------
// Compatible with HPOS
add_action( 'before_woocommerce_init', function() {
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
}
} );
}