Created
September 23, 2013 01:11
-
-
Save agusmu/6665449 to your computer and use it in GitHub Desktop.
WooCommerce - Add Box Frame to Product Image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Wrap product image with a box container. */ | |
add_action('prima_custom_scripts', 'prima_custom_product_image_box'); | |
function prima_custom_product_image_box() { | |
echo 'jQuery(document).ready(function($) {'; | |
echo '$(".woocommerce ul.products li.product a img, .woocommerce-page ul.products li.product a img").wrap("<div class=\'product-image-box\'></div>");'; | |
echo '$(".woocommerce ul.products li.product .onsale, .woocommerce-page ul.products li.product .onsale").each(function() { var item = $(this); item.prependTo(item.parent().find(".product-image-box")); });'; | |
echo '});'; | |
echo "\n"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* style product image box */ | |
.woocommerce ul.products li.product a .product-image-box, .woocommerce-page ul.products li.product a .product-image-box { | |
border-style: solid; | |
border-width: 5px; | |
border-color: #DDDDDD; | |
padding: 10px; | |
background-color: #FFFFFF; | |
} | |
/* reset padding and margin and remove shadow effect on product image */ | |
.woocommerce ul.products li.product a .product-image-box img, .woocommerce-page ul.products li.product a .product-image-box img { | |
padding: 0; | |
margin: 0; | |
-webkit-box-shadow: none; | |
box-shadow: none; | |
} | |
/* remove shadow effect on product image mouseover */ | |
.woocommerce ul.products li.product a:hover .product-image-box img, .woocommerce-page ul.products li.product a:hover .product-image-box img { | |
-webkit-box-shadow: none; | |
box-shadow: none; | |
} | |
/* repositioning sale sticker to product image corner, 5px border + 10px padding = 15px */ | |
.woocommerce ul.products li.product .product-image-box .onsale, .woocommerce-page ul.products li.product .product-image-box .onsale { | |
top: 15px; | |
left: 15px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tutorial: http://www.primathemes.com/documentation/woocommerce-add-box-frame-product-image/