PageSourceSearch

https://mindhachioji.org/js/DsFront/public/resize_img.js?=yytMfYN6YIgaO78fSgVzMQ

js mindhachioji.org collected 2026-10-08 02:55:27 UTC 4,025 bytes, 171 lines download raw bytes

1$.fn.getImgSize = function() {
2	var image = $(this).get(0);
3	var w = image.width,
4		h = image.height;
5
6	if (typeof image.naturalWidth !== 'undefined') {
7		w = image.naturalWidth;
8		h = image.naturalHeight;
9
10		if(!w || !h){
11			// 20210309 itayama naturalWidth取れていないときはImageオブジェクト生成してサイズ取得
12			var imageObj = new Image();
13			imageObj.src = $(image).attr("src");
14			w = imageObj.width;
15			h = imageObj.height;
16		}
17		
18	} else if (typeof image.runtimeStyle !== 'undefined') {
19		var run    = image.runtimeStyle;
20		var mem    = { w: run.width, h: run.height };  // keep runtimeStyle
21		run.width  = "auto";
22		run.height = "auto";
23		w          = image.width;
24		h          = image.height;
25		run.width  = mem.w;
26		run.height = mem.h;
27	} else {
28		var mem = { w: image.width, h: image.height };  // keep original style
29		image.removeAttribute("width");
30		image.removeAttribute("height");
31		w            = image.width;
32		h            = image.height;
33		image.width  = mem.w;
34		image.height = mem.h;
35	}
36
37	if (!w && !h) {
38		w = $(this).width();
39		h = $(this).height();
40	}
41
42	return {
43		width	: w,
44		height	: h
45	};
46}
47
48$.fn.setImgPos = function(maxwidth, maxheight) {
49	var $_this = $(this);
50	var w      = $_this.width();
51	var h      = $_this.height();
52	var top    = ((maxheight - h) / 2);
53
54/*
55	if (maxheight < h) {
56		top = top - (top * 2);
57	}
58*/
59	$_this.css("margin-top", top+"px");
60}
61
62$.fn.resizeImg = function(maxwidth, maxheight) {
63	if (!$(this).length) return;
64	//alert($(this).get(0).tagName);
65
66	var size    = $(this).getImgSize();
67	var wp = hp = 100;
68	var percent = 0;
69
70	if (maxwidth < size.width) {
71		wp = maxwidth/size.width * 100;
72	}
73	if (maxheight < size.height) {
74		hp = maxheight / size.height * 100;
75	}
76
77	if (wp <= hp) {
78		percent = wp;
79	} else if (hp < wp) {
80		percent = hp;
81	}
82
83	if (percent) {
84		w = Math.round(size.width * percent / 100);
85		h = Math.round(size.height * percent / 100);
86
87		$(this).width(w).height(h);
88
89		if ($(this).parent().hasClass("-amp-element")) {
90			$(this).parent().width(w).height(h);
91		}
92	}
93}
94
95$.fn.getResizeImg = function(maxwidth,maxheight) {
96	if (!$(this).length) return;
97
98	var size = $(this).getImgSize();
99	var wp = hp = 100;
100	var percent = 0;
101
102	if (maxwidth < size.width) {
103		wp = maxwidth/size.width * 100;
104	}
105	if (maxheight < size.height) {
106		hp = maxheight / size.height * 100;
107	}
108
109	if (wp <= hp) {
110		percent = wp;
111	} else if (hp < wp) {
112		percent = hp;
113	}
114
115	return {
116		width	: Math.round(size.width * percent / 100),
117		height	: Math.round(size.height * percent / 100)
118	};
119}
120
121$.fn.fitImgW = function(maxwidth, maxheight) {
122	if (!$(this).length) return;
123//alert($(this).get(0).tagName);
124	var size = $(this).getImgSize();
125//	if (size.width <= maxwidth) return;
126	// 表示サイズより小さい場合に行事が崩れる
127	if (size.width < maxwidth) {
128		maxwidth  = size.width;
129	}
130	if (size.height <= maxheight) {
131		maxheight = size.height;
132	}
133
134	var wp = hp = 100;
135	var percent = maxwidth / size.width * 100;
136
137	w = Math.round(size.width * percent / 100);
138	h = Math.round(size.height * percent / 100);
139
140	$(this).width(w).height(h);
141
142	if ($(this).parent().hasClass("-amp-element")) {
143		$(this).parent().width(w).height(h);
144	}
145}
146
147$.fn.fitImgH = function(maxwidth, maxheight) {
148	if (!$(this).length) return;
149	//alert($(this).get(0).tagName);
150	var size = $(this).getImgSize();
151//	if (size.width <= maxwidth) return;
152	// 表示サイズより小さい場合に行事が崩れる
153	if (size.width < maxwidth) {
154		maxwidth  = size.width;
155	}
156	if (size.height <= maxheight) {
157		maxheight = size.height;
158	}
159
160	var wp = hp = 100;
161	var percent = maxheight / size.height * 100;
162	w = Math.round(size.width * percent / 100);
163	h = Math.round(size.height * percent / 100);
164
165	$(this).width(w).height(h);
166
167	if ($(this).parent().hasClass("-amp-element")) {
168		$(this).parent().width(w).height(h);
169	}
170}
171

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.