"틀:이미지스와이퍼"의 두 판 사이의 차이

광주문화예술인문스토리플랫폼
이동: 둘러보기, 검색
69번째 줄: 69번째 줄:
 
         },
 
         },
 
       });
 
       });
// 이미지 로딩 실패 시 슬라이드 제거 후 Swiper 업데이트
+
 
document.querySelectorAll('.image-swiper-container .swiper-image').forEach(function(img) {
+
      // 이미지 로딩 타임아웃 및 에러 처리
img.addEventListener('error', function(e) {
+
      document.querySelectorAll('.image-swiper-container .swiper-image').forEach(function(img) {
console.log(e)
+
        var timeout;
this.closest('.swiper-slide').remove();
+
        var removeSlide = function() {
swiper.update();
+
          clearTimeout(timeout);
});
+
          img.closest('.swiper-slide').remove();
});
+
          swiper.update();
 +
        };
 +
 
 +
        // 3초 타임아웃 설정
 +
        timeout = setTimeout(function() {
 +
          if (!img.complete || img.naturalHeight === 0) {
 +
            removeSlide();
 +
          }
 +
        }, 1500);
 +
 
 +
        // 이미지 로딩 성공 시 타임아웃 취소
 +
        img.addEventListener('load', function() {
 +
          clearTimeout(timeout);
 +
        });
 +
 
 +
        // 이미지 로딩 실패 시 슬라이드 제거
 +
        img.addEventListener('error', function() {
 +
          removeSlide();
 +
        });
 +
      });
 
     });
 
     });
 
 
   </script>
 
   </script>
 
}}
 
}}
 
</includeonly>
 
</includeonly>

2025년 12월 24일 (수) 11:44 판