<?php
if ( ! defined( 'ABSPATH' ) ) exit;

$custom_sale_badge_upload = get_bodycommerce_option( 'custom_sale_badge_upload' );
  $BodyCommerce_sale_badge_size = get_bodycommerce_option( 'BodyCommerce_sale_badge_size' );
  $check_BodyCommerce_sale_badge_edge_distance = get_bodycommerce_option( 'BodyCommerce_sale_badge_edge_distance' );
  $check_BodyCommerce_sale_badge_top_distance = get_bodycommerce_option( 'BodyCommerce_sale_badge_top_distance' );
  $check_BodyCommerce_sale_badge_position = get_bodycommerce_option( 'BodyCommerce_sale_badge_position' );


  $aa_img_attachment = wp_get_attachment_image_src( $custom_sale_badge_upload );
  $path = $aa_img_attachment[0];
  ?>
  <img class="custom_user_badge sale" src="<?php echo $path ?>">
  <?php

  $css_badge = '
  <style id="bodycommerce-sale-badge user_custom">
.custom_user_badge.sale,
.woocommerce ul.products li.product a img.custom_user_badge.sale {
  width:'.$BodyCommerce_sale_badge_size .'px !important;
  max-height:'.$BodyCommerce_sale_badge_size .'px;
  position: absolute;
  z-index: 100;
  '.$check_BodyCommerce_sale_badge_position.':'.$check_BodyCommerce_sale_badge_edge_distance.'px;
  top: '.$check_BodyCommerce_sale_badge_top_distance.'px;
} 
</style>
';

$css_badge_min = str_replace( array("\r\n", "\r", "\n", "\t", '  ', '    ', '    '), '', $css_badge );
echo $css_badge_min;
