1$.fn.resizeImg = function(maxwidth, maxheight) { 2 if (!$(this).length) return; 3 //alert($(this).get(0).tagName); 4 5 var size = $(this).getImgSize(); 6 var wp = hp = 100; 7 var percent = 0; 8 9 if (maxwidth < size.width) { 10 wp = maxwidth/size.width * 100; 11 } 12 if (maxheight < size.height) { 13 hp = maxheight / size.height * 100; 14 } 15 16 if (wp <= hp) { 17 percent = wp; 18 } else if (hp < wp) { 19 percent = hp; 20 } 21 22 if (percent) { 23 w = Math.round(size.width * percent / 100); 24 h = Math.round(size.height * percent / 100); 25 26 $(this).width(w).height(h); 27 28 if ($(this).parent().hasClass("-amp-element")) { 29 $(this).parent().width(w).height(h); 30 } 31 } 32} 33 34$.fn.getResizeImg = function(maxwidth,maxheight) { 35 if (!$(this).length) return; 36 37 var size = $(this).getImgSize(); 38 var wp = hp = 100; 39 var percent = 0; 40 41 if (maxwidth < size.width) { 42 wp = maxwidth/size.width * 100; 43 } 44 if (maxheight < size.height) { 45 hp = maxheight / size.height * 100; 46 } 47 48 if (wp <= hp) { 49 percent = wp; 50 } else if (hp < wp) { 51 percent = hp; 52 } 53 54 return { 55 width : Math.round(size.width * percent / 100), 56 height : Math.round(size.height * percent / 100) 57 }; 58} 59 60$.fn.fitImgW = function(maxwidth, maxheight) { 61 if (!$(this).length) return; 62//alert($(this).get(0).tagName); 63 var size = $(this).getImgSize(); 64// if (size.width <= maxwidth) return; 65 // 表示ãµã¤ãºããå°ããå ´åã«è¡äºãå´©ãã 66 if (size.width < maxwidth) { 67 maxwidth = size.width; 68 } 69 if (size.height <= maxheight) { 70 maxheight = size.height; 71 } 72 73 var wp = hp = 100; 74 var percent = maxwidth / size.width * 100; 75 76 w = Math.round(size.width * percent / 100); 77 h = Math.round(size.height * percent / 100); 78 79 $(this).width(w).height(h); 80 81 if ($(this).parent().hasClass("-amp-element")) { 82 $(this).parent().width(w).height(h); 83 } 84} 85 86$.fn.fitImgH = function(maxwidth, maxheight) { 87 if (!$(this).length) return; 88 //alert($(this).get(0).tagName); 89 var size = $(this).getImgSize(); 90// if (size.width <= maxwidth) return; 91 // 表示ãµã¤ãºããå°ããå ´åã«è¡äºãå´©ãã 92 if (size.width < maxwidth) { 93 maxwidth = size.width; 94 } 95 if (size.height <= maxheight) { 96 maxheight = size.height; 97 } 98 99 var wp = hp = 100; 100 var percent = maxheight / size.height * 100; 101 w = Math.round(size.width * percent / 100); 102 h = Math.round(size.height * percent / 100); 103 104 $(this).width(w).height(h); 105 106 if ($(this).parent().hasClass("-amp-element")) { 107 $(this).parent().width(w).height(h); 108 } 109} 110 111$.fn.getImgSize = function() { 112 var image = $(this).get(0); 113 var w = image.width, 114 h = image.height; 115 116 if (typeof image.naturalWidth !== 'undefined') { 117 w = image.naturalWidth; 118 h = image.naturalHeight; 119 120 if(!w || !h){ 121 // 20210309 itayama naturalWidthåãã¦ããªãã¨ãã¯Imageãªãã¸ã§ã¯ãçæãã¦ãµã¤ãºåå¾ 122 var imageObj = new Image(); 123 imageObj.src = $(image).attr("src"); 124 w = imageObj.width; 125 h = imageObj.height; 126 } 127 } else if (typeof image.runtimeStyle !== 'undefined') { 128 var run = image.runtimeStyle; 129 var mem = { w: run.width, h: run.height }; // keep runtimeStyle 130 run.width = "auto"; 131 run.height = "auto"; 132 w = image.width; 133 h = image.height; 134 run.width = mem.w; 135 run.height = mem.h; 136 } else { 137 var mem = { w: image.width, h: image.height }; // keep original style 138 image.removeAttribute("width"); 139 image.removeAttribute("height"); 140 w = image.width; 141 h = image.height; 142 image.width = mem.w; 143 image.height = mem.h; 144 } 145 146 if (!w && !h) { 147 w = $(this).width(); 148 h = $(this).height(); 149 } 150 151 return { 152 width : w, 153 height : h 154 }; 155} 156 157$.fn.setImgPos = function(maxwidth, maxheight) { 158 var $_this = $(this); 159 var w = $_this.width(); 160 var h = $_this.height(); 161 var top = ((maxheight - h) / 2); 162 163/* 164 if (maxheight < h) { 165 top = top - (top * 2); 166 } 167*/ 168 $_this.css("margin-top", top+"px"); 169}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.