PageSourceSearch

https://aither.kr/js/image.js?1772780204

js aither.kr collected 2026-09-24 12:27:59 UTC 12,358 bytes, 466 lines download raw bytes

1var IMAGE_RESIZE = function(){
2	var code;
3	var $img_wrap, $obj, $parent, $text_wrap, $overlay_wrap, $hover_text_wrap, $hover_overlay_wrap;
4	var gh, r, img_ratio,h, pw, w, o, fix_height, fix_ratio;
5	var data;
6	var resize_timer = {};
7	var log_mode = false;
8
9	var init = function(c, d){
10		data = d;
11    
12		// console.log('data', data);
13    // 이미지 자체의 가로값
14		w = parseFloat(data.img_width);
15		logging('이미지넓이 w', w);
16    // 이미지 자체의 세로값
17		h = parseFloat(data.img_height);
18		logging('이미지높이 h', h);
19    // 이미지 자체의 비율
20		r = parseFloat(data.img_ratio);
21		logging('이미지비율 r', r);
22    // 이미지 고정 높이값, null인 경우, 이미지 비율에 따라 해당 길이 조정
23		gh = parseFloat(data.grid_height);
24		logging('그리드 높이 gh', gh);
25		o = data.org_size;
26		fix_height = data.fix_height;
27		fix_ratio = data.fix_ratio;
28		code = c;
29		$img_wrap = $('#'+code+' ._image_wrap');
30		$obj = $img_wrap.find("#img_" + code);
31		$parent = $obj.parent('._img_box');
32		$text_wrap = $obj.siblings('._txt_wrap');
33		$hover_text_wrap = $obj.siblings('._hover_txt_wrap');
34		$overlay_wrap = $obj.siblings('._overlay');
35		$hover_overlay_wrap = $obj.siblings('._hover_overlay');
36		img_ratio = Math.round((h * 100) / w) / 100;
37		var windowWidth = $(window).width();
38
39		$(window).off('resize.'+code)
40			.on('resize.'+code,function(){
41				if ($(window).width() != windowWidth) {
42					windowWidth = $(window).width();
43				}else{
44					return;
45				}
46				run();
47			});
48		$img_wrap.imagesLoaded()
49			.always(function(){
50				run();
51			});
52	};
53
54	var logging = function(type,value){
55		if(!log_mode)
56			return;
57		//$obj.attr('log-'+type, value);
58		console.log('log-'+type, value)
59	};
60
61	var run = function(){
62		setTimeout(function(){
63			$parent = $obj.parent('._img_box');
64			pw = $parent.width();
65
66			logging('pw', pw);
67
68			if(typeof o == 'undefined'){
69				o = false;
70			}
71
72			if(o == 'Y'){
73				runOrgImageResize();
74			}else{
75				runFitImageResize();
76			}
77		}, 50);
78	};
79	var runOrgImageResize = function(){
80		if($obj.length == 0)
81			return;
82		logging('type', 'org');
83		//console.log('원본 크기인 경우');
84		logging('gh1', typeof gh);
85		logging('gh2', parseInt(gh));
86		if(typeof gh === 'undefined' || gh === 0){
87			gh = Math.round(pw * r);
88		}
89		var fix_ratio = Math.round((gh * 100) / pw) / 100;
90
91		logging('r', r);
92		logging('gh', gh);
93		logging('img_ratio', img_ratio);
94		logging('fix_ratio', fix_ratio);
95		if(img_ratio > fix_ratio){
96			logging('1', 1);
97			//console.log('제한한 비율보다 이미지의 높이가 길쭉한 경우');
98			var h_term = 0;
99			if(h > gh){
100				logging('11', 1);
101				//console.log('제한한 높이 보다 이미지의 원본 높이가 높은 경우');
102				$obj.css({
103					'display' : 'inline-block',
104					'width' : 'auto',
105					'height' : Math.round(gh),
106					'margin' : Math.round(h_term) + 'px auto'
107				});
108
109			}else{
110				logging('11', 2);
111				h_term = Math.round((gh - h) / 2);
112				//console.log('제한한 높이 보다 이미지의 원본 높이가 낮은 경우');
113				$obj.css({
114					'display' : 'inline-block',
115					'width' : 'auto',
116					'height' : Math.round(h),
117					'margin' : h_term + 'px auto'
118				});
119			}
120			$parent.css('height',Math.round($obj.height()+(h_term*2)));
121			if($text_wrap.length >0){
122				logging('12', 1);
123				$text_wrap.css({
124					'position' : 'relative',
125					'margin' : 'auto',
126					'margin-top' : Math.round($obj.height()+h_term) * (-1),
127					'margin-bottom' : h_term == 0 ? 'auto' : Math.round(h_term) + 'px',
128					'width' : $obj.width(),
129					'height' : Math.round($obj.height()),
130					'top' : '0',
131					'left' : '0'
132				});
133
134				$text_wrap.find('span.txt_body').css({
135					'height' : Math.round($obj.height()),
136				});
137			}
138			if($hover_text_wrap.length >0){
139				logging('13', 1);
140				$hover_text_wrap.css({
141					'position' : 'relative',
142					'margin' : 'auto',
143					'margin-top' : Math.round($obj.height()+h_term) * (-1),
144					'margin-bottom' : h_term == 0 ? 'auto' : Math.round(h_term) + 'px',
145					'width' : $obj.width(),
146					'height' : Math.round($obj.height()),
147					'top' : '0',
148					'left' : '0'
149				});
150
151				$hover_text_wrap.find('span.txt_body').css({
152					'height' : Math.round($obj.height()),
153				});
154			}
155			if($overlay_wrap.length >0){
156				logging('14', 1);
157				$overlay_wrap.css({
158					'position' : 'relative',
159					'margin' : 'auto',
160					'margin-top' : Math.round($obj.height()+h_term) * (-1),
161					'margin-bottom' : h_term == 0 ? 'auto' : Math.round(h_term) + 'px',
162					'width' : $obj.width() == 0 ? Math.round($obj.height()) : $obj.width(),
163					'height' : Math.round($obj.height()),
164					'top' : '0',
165					'left' : '0'
166				});
167			}
168			if($hover_overlay_wrap.length >0){
169				logging('15', 1);
170				$hover_overlay_wrap.css({
171					'position' : 'relative',
172					'margin' : 'auto',
173					'margin-top' : Math.round($obj.height()+h_term) * (-1),
174					'margin-bottom' : h_term == 0 ? 'auto' : Math.round(h_term) + 'px',
175					'width' : $obj.width(),
176					'height' : Math.round($obj.height()),
177					'top' : '0',
178					'left' : '0'
179				});
180			}
181			if(!isBlank(data.hover_thumb_url)){
182				logging('16', 1);
183				$parent.find('._hover_image').remove();
184				var $hover_img = $('<div />').addClass('_hover_image hover_img');
185				if(data.circle == 'Y'){
186					logging('161', 1);
187					$hover_img.addClass(' circle');
188				}
189				$hover_img.css({
190					'position' : 'relative',
191					'margin' : 'auto',
192					'margin-top' : Math.round($obj.height()+h_term) * (-1),
193					'margin-bottom' : h_term == 0 ? 'auto' : Math.round(h_term) + 'px',
194					'width' : $obj.width(),
195					'height' : Math.round($obj.height()),
196					'background-image' : 'url(' + data.hover_thumb_url + ')',
197					'background-size' : 'cover',
198					'background-repeat' : 'no-repeat',
199					'background-position' : '50% 50%',
200					'top' : '0',
201					'left' : '0'
202				});
203				$parent.append($hover_img);
204			}
205		}else{
206			logging('1', 2);
207			if(w > pw){
208				logging('21', 1);
209				var fix_h = pw * img_ratio;
210				var h_term = Math.round((gh - fix_h) / 2);
211				$obj.css({
212					'display' : 'inline-block',
213					'width' : pw,
214					'height' : 'auto',
215					'margin-top' : h_term + 'px',
216					'margin-bottom' : h_term + 'px',
217					'margin-left' : 'auto',
218					'margin-right' : 'auto'
219				});
220
221			}else{
222				logging('21', 2);
223				var w_term = (pw - w) / 2;
224				var fix_h = w * img_ratio;
225				var h_term = (gh - fix_h) / 2;
226				var ma = h_term > 0 ? h_term + 'px ' : 'auto ';
227				$obj.css({
228					'display' : 'inline-block',
229					'width' : w,
230					'height' : 'fit-content',
231					'margin' : Math.round(ma + w_term) + 'px'
232				});
233			}
234			if($text_wrap.length >0){
235				logging('22', 1);
236				$text_wrap.css({
237					'position' : 'absolute',
238					'top' : '50%',
239					'left' : '50%',
240					'margin-top' : Math.round($obj.height()/2) * (-1),
241					'margin-left' : ($obj.width()/2) * (-1),
242					'width' : $obj.width(),
243					'height' : Math.round($obj.height())
244				});
245
246				$text_wrap.find('span.txt_body').css({
247					'height' : Math.round($obj.height())
248				});
249			}
250
251			if($hover_text_wrap.length >0){
252				logging('23', 1);
253				$hover_text_wrap.css({
254					'position' : 'absolute',
255					'top' : '50%',
256					'left' : '50%',
257					'margin-top' : Math.round($obj.height()/2) * (-1),
258					'margin-left' : ($obj.width()/2) * (-1),
259					'width' : $obj.width(),
260					'height' : Math.round($obj.height()),
261				});
262
263				$hover_text_wrap.find('span.txt_body').css({
264					'height' : Math.round($obj.height()),
265				});
266			}
267			if($overlay_wrap.length >0){
268				logging('24', 1);
269				$overlay_wrap.css({
270					'position' : 'absolute',
271					'top' : '50%',
272					'left' : '50%',
273					'margin-top' : Math.round($obj.height()/2) * (-1),
274					'margin-left' : ($obj.width()/2) * (-1),
275					'width' : $obj.width(),
276					'height' : Math.round($obj.height()),
277				});
278			}
279
280			if($hover_overlay_wrap.length >0){
281				logging('25', 1);
282				$hover_overlay_wrap.css({
283					'position' : 'absolute',
284					'top' : '50%',
285					'left' : '50%',
286					'margin-top' : Math.round($obj.height()/2) * (-1),
287					'margin-left' : ($obj.width()/2) * (-1),
288					'width' : $obj.width(),
289					'height' : Math.round($obj.height()),
290				});
291			}
292			if(!isBlank(data.hover_thumb_url)){
293				logging('26', 1);
294				$parent.find('._hover_image').remove();
295				var $hover_img = $('<div />').addClass('_hover_image hover_img');
296				const test = $obj.height();
297				const imgHeight = $obj.height() === 0 ? ($obj.width() * data.img_ratio) : $obj.height();
298				logging('img_heignt', imgHeight);
299				if(data.circle == 'Y'){
300					logging('261', 1);
301					$hover_img.addClass(' circle');
302				}
303				$hover_img.css({
304					'position' : 'absolute',
305					'top' : '50%',
306					'left' : '50%',
307					'margin-top' : Math.round(imgHeight/2) * (-1),
308					'margin-left' : Math.round($obj.width()/2) * (-1),
309					'width' : $obj.width(),
310					'height' : Math.round(imgHeight),
311					'background-image' : 'url(' + data.hover_thumb_url + ')',
312					'background-size' : 'cover',
313					'background-repeat' : 'no-repeat',
314					'background-position' : '50% 50%'
315				});
316				$obj.css({ 'height' : Math.round(imgHeight), });
317				$parent.append($hover_img);
318			}
319		}
320
321		if ( $img_wrap.closest('._widget_data').hasClass('wg_animated') ) {
322			$obj.css('visibility','inherit');
323		} else {
324			$obj.css('visibility','visible');
325		}
326
327		// console.log('$obj.width()', $obj.width());
328		// console.log('$obj.height()', $obj.height());
329
330
331	};
332
333	var runFitImageResize = function(){
334		logging('type', 'fit');
335		if($parent.css('position') != 'absolute'){
336			if(fix_height == 'Y'){
337				logging('type', 'fit height');
338				$parent.height(Math.round(gh));
339			} else if ( fix_ratio == 'Y' ) {
340				logging('type', 'fit ratio');
341				const imgHeight = data.img_height;
342				const imgWidth = data.img_width;
343				const imgRatio = imgHeight / imgWidth;
344				$parent.height(Math.round(pw * imgRatio));
345			} else {
346				$parent.height(Math.round(pw * r));
347			}
348		}
349
350		if(r != h / w){
351			logging('1', 1);
352			var ph = $parent.height();
353			logging('부모 높이 ph', ph);
354			var wr = pw / w;
355			logging('pw /w = wr', wr);
356
357			if(wr * h > ph){
358				logging('11', 1);
359				$obj.css({
360					'display' : 'block',
361					'width' : '100%',
362					'height' : 'auto',
363					'margin-top' : Math.round((h * wr - ph) / 2) * (-1),
364					'margin-left' : 0
365				})
366			}else{
367				logging('11', 2);
368				var hr = ph / h;
369				$obj.css({
370					'display' : 'block',
371					'width' : 'auto',
372					'height' : '100%',
373					'margin-top' : 0,
374					'margin-left' : -(w * hr - pw) / 2
375				})
376			}
377		}else{
378			logging('1', 2);
379			$obj.css({
380				'display' : 'bock',
381				'width' : '100%',
382				'height' : '100%',
383				'object-fit' : 'cover',
384				'margin-top' : 0,
385				'margin-left' : 0
386			})
387		}
388
389		if($text_wrap.length >0){
390			$text_wrap.css({
391				'position' : 'absolute',
392				'width' : '100%',
393				'height' : '100%',
394				'top' : 0,
395				'left' : 0
396			});
397
398			$text_wrap.find('span.txt_body').css({
399				'height' : Math.round($parent.height()),
400			});
401		}
402		if($hover_text_wrap.length >0){
403			$hover_text_wrap.css({
404				'position' : 'absolute',
405				'width' : '100%',
406				'height' : '100%',
407				'top' : 0,
408				'left' : 0
409			});
410
411			$hover_text_wrap.find('span.txt_body').css({
412				'height' : Math.round($parent.height()),
413			});
414		}
415		if($overlay_wrap.length >0){
416			$overlay_wrap.css({
417				'position' : 'absolute',
418				'width' : '100%',
419				'height' : '100%',
420				'top' : 0,
421				'left' : 0,
422			});
423		}
424
425		if($hover_overlay_wrap.length >0){
426			$hover_overlay_wrap.css({
427				'position' : 'absolute',
428				'width' : '100%',
429				'height' : '100%',
430				'top' : 0,
431				'left' : 0
432			});
433		}
434
435		if(!isBlank(data.hover_thumb_url)){
436			$parent.find('._hover_image').remove();
437			var $hover_img = $('<div />').addClass('_hover_image hover_img');
438			if(data.circle == 'Y')
439				$hover_img.addClass(' circle');
440			$hover_img.css({
441				'position' : 'absolute',
442				'width' : '100%',
443				'height' : '100%',
444				'top' : 0,
445				'left' : 0,
446				'background-image' : 'url(' + data.hover_thumb_url + ')',
447				'background-size' : 'cover',
448				'background-repeat' : 'no-repeat',
449				'background-position' : '50% 50%'
450			});
451			$parent.append($hover_img);
452		}
453		if ( $img_wrap.closest('._widget_data').hasClass('wg_animated') ) {
454			$obj.css('visibility','inherit');
455		} else {
456			$obj.css('visibility','visible');
457		}
458
459	};
460
461	return {
462		'init' : function(c,data){
463			init(c, data);
464		}
465	}
466};

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.