"틀:동영상스와이퍼"의 두 판 사이의 차이

광주문화예술인문스토리플랫폼
이동: 둘러보기, 검색
202번째 줄: 202번째 줄:
 
           if (iframe.src) {
 
           if (iframe.src) {
 
             if (!iframe.src.includes("youtu")) return;
 
             if (!iframe.src.includes("youtu")) return;
             // & 이후 파라미터 제거
+
 
             const ampIndex = iframe.src.indexOf("&");
+
             // 기존 URL에서 ?와 & 모두 제거하고 깨끗한 embed URL만 추출
             if (ampIndex !== -1) {
+
             let cleanUrl = iframe.src;
               iframe.src = iframe.src.substring(0, ampIndex);
+
            const questionIndex = cleanUrl.indexOf("?");
 +
            const ampIndex = cleanUrl.indexOf("&");
 +
 
 +
             if (questionIndex !== -1) {
 +
              cleanUrl = cleanUrl.substring(0, questionIndex);
 +
            } else if (ampIndex !== -1) {
 +
               cleanUrl = cleanUrl.substring(0, ampIndex);
 
             }
 
             }
 +
 
             // enablejsapi=1 파라미터 추가
 
             // enablejsapi=1 파라미터 추가
             if (!iframe.src.includes("enablejsapi=1")) {
+
             iframe.src = cleanUrl + "?enablejsapi=1";
              iframe.src =
 
                iframe.src +
 
                (iframe.src.includes("?") ? "&" : "?") +
 
                "enablejsapi=1";
 
            }
 
 
           }
 
           }
 
         });
 
         });
291번째 줄: 293번째 줄:
 
{{#tag:html|
 
{{#tag:html|
 
   <script src="https://unpkg.com/swiper@8/swiper-bundle.min.js"></script>
 
   <script src="https://unpkg.com/swiper@8/swiper-bundle.min.js"></script>
}}  
+
}}
== 템플릿 사용 예제 ==  
+
== 템플릿 사용 예제 ==
{{동영상스와이퍼  
+
{{동영상스와이퍼
 
   | https://www.youtube.com/embed/MlM1fbaHZTQ
 
   | https://www.youtube.com/embed/MlM1fbaHZTQ
   | https://www.youtube.com/watch?v-nN6hHjH2O-c  
+
   | https://www.youtube.com/watch?v-nN6hHjH2O-c
   | https://www.youtube.com/watch?v-nN6hHjH2O-c  
+
   | https://www.youtube.com/watch?v-nN6hHjH2O-c
 
}}
 
}}
  

2025년 12월 29일 (월) 09:57 판


템플릿 사용 예제



== 템플릿 사용 예제 ==
{{동영상스와이퍼
  | https://www.youtube.com/embed/MlM1fbaHZTQ&list-RDMlM1fbaHZTQ&start_radio-1?enablejsapi=1
  | https://www.youtube.com/watch?v-nN6hHjH2O-c
  | https://www.youtube.com/watch?v-nN6hHjH2O-c
}}

 위 예제는 동영상 스와이퍼 템플릿 사용 예시입니다. watch?v- 형식의 유튜브 URL을
 입력하면 자동으로 embed 형식으로 변환됩니다.