|
|
|
|
- function imgProportion($targetWidth, $targetHeight)
- {
- var DeviceWidth = parseInt($(window).width()-15); //화면의 가로 사이즈
- var a1 = DeviceWidth * $targetHeight; //이미지 세로사이즈 계산식
- var newHeight = (a1 / $targetWidth); //이미지 세로사이즈 계산식
- var rtnSize = new Array((DeviceWidth), newHeight); //리사이징 된 이미지 사이즈 리턴
-
- return rtnSize;
- }
- $("img", main).each(function() //이미지를 FIND.
- {
- var $this = $(this); //선택자를 지정.
- var $thisWidth = parseInt($this.css("width")); //선택된 이미지의 가로사이즈.
- var $thisHeight = parseInt($this.css("height")); //선택된 이미지의 세로사이즈.
- var clientWidth = parseInt($(window).width()); //화면의 가로사이즈.
-
- if($thisWidth > clientWidth) //이미지 가로가 화면의 가로보다 길다면..
- {
- var rtn = imgProportion($thisWidth, $thisHeight);
- var newWidth = rtn[0]; //Return 된 배열의 0번째 값.
- var newHeight = rtn[1]; //Return 된 배열의 1번째 값.
-
- $this.css({ //선택된 이미지에 CSS를 변경.
-
- "width" : newWidth,
- "height" : newHeight
- })
- }
- });
- // 동영상을 공유한 사이트의 이름을 배열로 저장한다.
- // 새로운 사이트나 없어진 사이트가 있으면 그때 그때 업데이트 해주세요~
- var $allVideos = $("iframe[src^='http://player.vimeo.com'], iframe[src^='http://www.youtube.com'], iframe[src^='http://www.youtube-nocookie.com'], iframe[src^='http://serviceapi.nmv.naver.com'], iframe[src^='http://serviceapi.rmcnmv.naver.com'], embed[src^='http://www.youtube.com'], embed[src^='http://serviceapi.nmv.naver.com'], iframe[src^='https://www.youtube.com'], iframe[src^='https://www.youtube-nocookie.com'], iframe[src^='http://flvs.daum.net'], iframe[src^='http://play.pullbbang.com'], iframe[src^='http://www.gamespot.com'], iframe[src^='http://sbsplayer.sbs.co.kr/'], iframe[src^='http://www.microsoft.com'], iframe[src^='http://dotsub.com'], iframe[src^='http://www.travelro.co.kr'], embed[src^='http://v.egloos.com/v.sk/'], embed[src^='http://videofarm.daum.net/'] ,embed[src^='http://api.v.daum.net/'], embed[src^='http://dory.mncast.com/'], embed[src^='http://play.mgoon.com/Video/'], embed[src^='http://doc.mgoon.com/'], embed[src^='http://flvr.pandora.tv/flv2pan/'], embed[src^='http://imgcdn.pandora.tv/'], embed[src^='http://live.afreeca.com'], embed[src^='http://afbbs.afreeca.com'], embed[src^='http://w.blogdoc.nate.com'], embed[src^='http://blogdoc.nate.com'], embed[src^='http://www.musicshake.com/'], embed[src^='http://static.plaync.co.kr'], iframe[src^='http://www.travelro.co.kr'], iframe[src^='http://dotsub.com']"),
-
- $fluidEl = $("body"); // 자동리사이징을 적용할 영역의 ID값
-
- $allVideos.each(function()
- {
- $(this)
- .data('aspectRatio', this.height / this.width)
- // 기존 높,넓 삭제
- .removeAttr('height')
- .removeAttr('width');
-
- });
-
- $(window).resize(function()
- {
- var newWidth = $fluidEl.width();
-
- $allVideos.each(function()
- {
- var $el = $(this);
- $el
- .width('100%') // 원하는데로~~
- .height('260'); // 원하는데로~~
- });
- }).resize();
이상! 입니다. 모바일은 물론 PC버전에서도 적용 가능 합니다.
- PC버전! - 모바일버전! |
|
|
|
|
|
|
|
|
|
공유하기
|
공유하기
|
|
|
|
|
|
|