사용후기 상품문의 이미지 리사이즈 스크립트 추가

This commit is contained in:
chicpro
2013-10-02 15:47:01 +09:00
parent 6f57cde452
commit ecc8b3b5f4
9 changed files with 101 additions and 9 deletions

44
js/iteminfoimageresize.js Normal file
View File

@ -0,0 +1,44 @@
(function($) {
$.fn.iteminfoimageresize = function(selector)
{
var cfg = {
selector: "img"
};
if(typeof selector == "object") {
cfg = $.extend(cfg, selector);
} else {
if(selector) {
cfg = $.extend({ selector: selector });
}
}
var $img = this.find(cfg.selector);
var $this = this;
function image_resize()
{
var width = $this.width();
$img.each(function() {
$(this).removeAttr("width")
.removeAttr("height")
.css("width","")
.css("height", "");
if($(this).data("width") == undefined)
$(this).data("width", $(this).width());
if($(this).data("width") > width) {
$(this).css("width", "100%");
}
});
}
$(window).on("resize", function() {
image_resize();
});
image_resize();
}
}(jQuery));