ํฐ์คํ ๋ฆฌ ๋ธ๋ก๊ทธ์ ์ ํ๋ธ ๋์์ ๋ฆฌ์คํธ ์๋ ์์ฑํ๋ ๋ฐฉ๋ฒ
์ ํ๋ธ ์์ ๋ธ๋ก๊ทธ ์ฝ์ ๋ฐฉ๋ฒ๊ณผ ๋ฐ์ํ ๋์์ธ ์ต์ ํ
ํฐ์คํ ๋ฆฌ ๋ธ๋ก๊ทธ ๋์์ ๋ฆฌ์คํธ ๋ง๋ค๊ธฐ
๋ธ๋ก๊ทธ๋ฅผ ์ด์ํ๋ฉด์ ๊ธ๋ง์ผ๋ก ์ฝํ ์ธ ๋ฅผ ์ ๋ฌํ๋ ๋ฐ ํ๊ณ๊ฐ ๋๊ปด์ง ๋๊ฐ ์์ต๋๋ค. ํนํ ์์ฆ์ฒ๋ผ ๋ค์ํ ํ์์ ๋ฏธ๋์ด ์๋น๊ฐ ํ์ฑํ๋ ์๋์์๋ ๊ธ๋ง์ผ๋ก๋ ๋ ์๋ค์๊ฒ ์ถฉ๋ถํ ์ ๋ณด๋ฅผ ์ ๋ฌํ๊ธฐ ์ด๋ ค์ด ๊ฒฝ์ฐ๊ฐ ๋ง์ต๋๋ค. ์ด๋ด ๋ ์ ์ฉํ ๋๊ตฌ๊ฐ ๋ฐ๋ก ๋์์์ ๋๋ค.
์ ํ๋ธ ์ฑ๋์ ์ด์ ์ค์ด๊ฑฐ๋ ๋์์ ์ฝํ ์ธ ๋ฅผ ์ ์ํ๋ ๋ธ๋ก๊ฑฐ๋ผ๋ฉด, ์์ ์ ๋ธ๋ก๊ทธ์ ๋์์์ ํจ๊ณผ์ ์ผ๋ก ํตํฉํ๋ ๊ฒ์ ๋ ์ด์ ์ ํ์ด ์๋ ํ์๊ฐ ๋์์ต๋๋ค. ์ด ๊ธ์์๋ ๋ธ๋ก๊ทธ์ ๋์์์ ๊ณต์ ํ๊ณ , ๋ธ๋ก๊ทธ ์คํจ์ ์์ ํ์ฌ ์ด๋ฅผ ์ ๋ ธ์ถ์ํค๋ ๋ฐฉ๋ฒ์ ๋ํด ๋ค๋ค๋ณด๊ฒ ์ต๋๋ค.
๋ธ๋ก๊ทธ์์ ๋์์์ ์ค์์ฑ
๊ธฐ์กด์ ๋ธ๋ก๊ทธ๋ ๊ธ๊ณผ ์ด๋ฏธ์ง ์ค์ฌ์ผ๋ก ์ด์๋๋ ๊ฒฝ์ฐ๊ฐ ๋ง์์ต๋๋ค. ํ์ง๋ง ์ด์ ๋ ๋์์ ์ฝํ ์ธ ๋ฅผ ๊ฒฐํฉํ ๋ธ๋ก๊ทธ ์ด์์ด ํ์์ ์ธ ์์๋ก ์๋ฆฌ์ก๊ณ ์์ต๋๋ค. ํนํ ์ ํ๋ธ๋ Vimeo์ ๊ฐ์ ํ๋ซํผ์์ ๋์์์ ์ ์ํ๊ณ ์ด์ํ๋ ๋ธ๋ก๊ฑฐ๊ฐ ๋์ด๋๋ฉด์, ์ด๋ฅผ ๋ธ๋ก๊ทธ์ ํตํฉํ๋ ๊ฒ์ด ํธ๋ ๋๋ก ์๋ฆฌ์ก์์ต๋๋ค.
๋์์์ ๊ธ๋ณด๋ค ์ง๊ด์ ์ด๊ณ ๋น ๋ฅด๊ฒ ์ ๋ณด๋ฅผ ์ ๋ฌํ ์ ์๋ ์ฅ์ ์ด ์์ต๋๋ค. ๋ํ, ์์ ์ฝํ ์ธ ๋ ์์ฒญ๊ฐ์ ์ธ ์์๊ฐ ๊ฒฐํฉ๋์ด ๋ ์์ ๊ด์ฌ์ ๋๊ธฐ ๋ ์ฉ์ดํฉ๋๋ค.
์๋ฅผ ๋ค์ด, ์ ํ๋ธ ์์ ์์ ๊ฐ์๋ ๋ฆฌ๋ทฐ, ํํ ๋ฆฌ์ผ ๋ฑ์ ๋ด์๋๋ฉด, ๋ฐฉ๋ฌธ์๋ ๊ธ๋ก๋ง ์ค๋ช ํ๋ ๊ฒ๋ณด๋ค ์์์ผ๋ก ์ง์ ๋ณด๋ ๊ฒ์ด ํจ์ฌ ์ ์ตํ๊ณ ์ดํด๊ฐ ๋น ๋ฅผ ์ ์์ต๋๋ค. ๋ํ, ๋ธ๋ก๊ทธ์ ๋ฐฉ๋ฌธ์ ์๊ฐ ๋ง์์ง์๋ก ๋์์ ์ฝํ ์ธ ๋ ๋์ฑ ์ค์ํ ์ญํ ์ ํ๊ฒ ๋ฉ๋๋ค.
๋ธ๋ก๊ทธ ์คํจ ์์ ์ ์ ์ ์กฐ๊ฑด
๊ทธ๋ ๋ค๋ฉด ํฐ์คํ ๋ฆฌ ๋ธ๋ก๊ทธ์ ๋์์์ ์ด๋ป๊ฒ ํตํฉํ ์ ์์๊น์?
์ฐ์ , ๋ธ๋ก๊ทธ ์คํจ์ ์์ ํ๋ฉด ๋ฉ๋๋ค. ๊ธฐ๋ณธ์ ์ธ ์คํจ์ ํ ์คํธ ๊ธฐ๋ฐ์ ์ฝํ ์ธ ์๋ ์ ํฉํ์ง๋ง, ๋์์ ์ฝํ ์ธ ๋ฅผ ํจ๊ณผ์ ์ผ๋ก ๋ ธ์ถ์ํค๊ธฐ์๋ ๋ถ์กฑํ ์ ์์ต๋๋ค. ๋ฐ๋ผ์, ๋ธ๋ก๊ทธ์ ์คํจ์ ๋์์ ์ฝํ ์ธ ์ ๋ ์ ์ด์ธ๋ฆฌ๋๋ก ์์ ํด์ผ ํฉ๋๋ค.
์๋๋ ์นดํ ๊ณ ๋ฆฌ ํ์ด์ง์ ์๋์ผ๋ก ์ ํ๋ธ ๋์์์ด ์๋๋ ธ์ถ๋๋ ๋ฐฉ๋ฒ์ ๋๋ค.
1. ๋์์ ์ ์ฉ ์์ญ ์ ํ
๋ธ๋ก๊ทธ ์คํจ์ ์์ ํ ๋, ๋์์ ์ ์ฉ ์์ญ์ ๋ง๋๋ ๊ฒ์ด ์ข์ต๋๋ค. ๋์์ ์ ์ฉ ์์ญ์ ๋ธ๋ก๊ทธ์ ๋ฉ์ธ ์ฝํ ์ธ ๋ถ๋ถ๊ณผ ์นดํ ๊ณ ๋ฆฌ ํ์ด์ง ์ฌ์ด๋๊ฐ ์๋ ๋ธ๋ก๊ทธ๋ ์ต์ ๊ธ๊ณผ ์ธ๊ธฐ๊ธ์ ์ฝ์ ํ๋ ๋ฐฉ๋ฒ์ ๋๋ค.
2. ๋์์ ํ๋ ์ด์ด์ ์ฐ๋
๋ธ๋ก๊ทธ ์คํจ์ ์์ ํ๋ ๋ ๋ค๋ฅธ ์ค์ํ ๋ถ๋ถ์ ๋์์ ํ๋ ์ด์ด์์ ์ฐ๋์ ๋๋ค. ์ ํ๋ธ๋ Vimeo์ ๊ฐ์ ์ธ๋ถ ๋์์ ํ๋ซํผ์ ๋์์์ ์ฝ์ ํ ๋, ๋์์์ ํฌ๊ธฐ์ ์์น๋ฅผ ์ต์ ํํด์ผ ํฉ๋๋ค. ์๋ฅผ ๋ค์ด, ๋ชจ๋ฐ์ผ ํ๋ฉด์์๋ ๊นจ์ง์ง ์๊ณ ์ ๋ณด์ผ ์ ์๋๋ก ๋ฐ์ํ ๋์์ธ์ ์ ์ฉํ๋ ๊ฒ์ด ์ค์ํฉ๋๋ค.
๋ํ, ๋ธ๋ก๊ทธ ๋์์ธ์ ๋ง๊ฒ ์์ ์ธ๋ค์ผ์ด๋ ์ฌ์ ๊ธฐ๋ฅ์ ์ค์ ํ์ฌ ์ฌ์ฉ์ ํธ๋ฆฌ๋ฅผ ๋์ด๋ ๊ฒ์ด ์ข์ต๋๋ค.
3. ๋์์ ๊ท ํ ๋ง์ถ๊ธฐ
๋ธ๋ก๊ทธ๋ ๊ธ๊ณผ ์ด๋ฏธ์ง, ๊ทธ๋ฆฌ๊ณ ๋์์์ด ์กฐํ๋ฅผ ์ด๋ฃจ์ด์ผ ํฉ๋๋ค. ๋ฐ๋ผ์ ํ ์คํธ์ ๋์์์ ๊ท ํ์ ์ ๋ง์ถ๋ ๊ฒ์ด ์ค์ํฉ๋๋ค. ๋ธ๋ก๊ทธ ๊ธ์ ์์ฑํ ๋, ๋์์์ ๋ด์ฉ๊ณผ ๊ด๋ จ๋ ๊ฐ๋จํ ์๊ฐ๋ ์์ฝ์ ํจ๊ป ์ฒจ๋ถํด๋๋ฉด ๋ฐฉ๋ฌธ์๊ฐ ๊ธ๊ณผ ์์์ ๋์์ ์ดํดํ ์ ์์ด ์ข์ต๋๋ค.
๋ธ๋ก๊ทธ ์คํจ ์์ ๋ฐฉ๋ฒ
1. ์ ํ๋ธ ์์ ์๋ฒ ๋ ์ฝ๋ ์ฝ์
์ ํ๋ธ ์์ ์๋ฒ ๋ ์ฝ๋๋ฅผ ์ฌ์ฉํ์ฌ ์ ํ๋ธ์ ์ ๋ก๋๋ ๋์์์ ๋ธ๋ก๊ทธ์ ์ฝ์ ํ๋ ๋ฐฉ๋ฒ์ ๋งค์ฐ ๊ฐ๋จํฉ๋๋ค. ์ด ๋ฐฉ๋ฒ์ ์ ํ๋ธ์์ ์ ๊ณตํ๋ ๊ธฐ๋ณธ์ ์ธ ๊ธฐ๋ฅ์ผ๋ก, ๋ณ๋์ ๋ณต์กํ ์ฝ๋ ์์ ์์ด ๋น ๋ฅด๊ฒ ๋์์์ ๋ธ๋ก๊ทธ์ ์ฝ์ ํ ์ ์์ต๋๋ค.
์ ํ๋ธ ์๋ฒ ๋ ์ฝ๋ ์ฝ์ ๋ฐฉ๋ฒ
- ์ ํ๋ธ์์ ์์ ์ฐพ๊ธฐ ๋จผ์ , ์ ํ๋ธ์์ ์ฝ์ ํ ์์์ ์ฐพ์ต๋๋ค.
- '๊ณต์ ' ๋ฒํผ ํด๋ฆญ ์์ ํ๋จ์ ์๋ ๊ณต์ ๋ฒํผ์ ํด๋ฆญํฉ๋๋ค.
- '์๋ฒ ๋' ์ต์ ์ ํ '๊ณต์ ' ์ต์ ์์ HTML ์ฝ๋๊ฐ ๋ํ๋ฉ๋๋ค.
- HTML ์ฝ๋ ๋ณต์ฌ ์ ๊ณต๋ ์ฃผ์ HTML ์ฝ๋๋ฅผ ๋ณต์ฌํฉ๋๋ค.
๊ธํ์ด์ง ์ค ์ ๋นํ ์์น์ ์๋ ์ฝ๋์ ๋์์ ์ฃผ์๋ฅผ ๋ฃ์ด์ฃผ์๋ฉด ๋ฉ๋๋ค.
<p class="youtubeurl" data-ke-size="size16" style="user-select: auto !important;">
https://youtu.be/0jC-sW5l4_g?si=SrofVXVTTWtQH2a4</p>
๋ฐฉ๋ฒ์ ์ฌ์ฉํ๋ฉด ์ด๋ฏธ์ง์ ๋์์์ด ์์ฐ์ค๋ฝ๊ฒ ์ฝ์ ๋์ด ๋ฐฉ๋ฌธ์๋ ๋์์์ ๋ฐ๋ก ๋ณผ์ ์์ต๋๋ค ๋ํ, ๋ธ๋ก๊ทธ ๋์์ธ์ ๋ง๊ฒ ๋์์์ ํฌ๊ธฐ์ ์์น๋ฅผ ์กฐ์ ํ ์ ์์ด, ์ฝํ ์ธ ์ ์ด์ธ๋ฆฌ๋ ์ต์ ์ ์์น๋ฅผ ๋ง๋ค ์ ์์ต๋๋ค.
์ฌ์ฉ ์์
์ด ์ฌ์ดํธ๋ฅผ ์ด๋ํ๋ฉด ์๋ ์ฝ๋๋ฅผ ์ ์ฉํ ๊ฒฐ๊ณผ๋ฅผ ๋ณผ์ ์์ต๋๋ค.
<s_list>
<div class="wrap_content">
<div id="content_search_list" class="content content_article_rep">
<div class="inner_content">
<div id="content_search" class="content sub_content">
<div class="inner_content">
<div class="section_area">
<h2 class="tit_section">
<span class="txt_section"></span>
</h2>
<ul class="list_article list_sub list_sub_type1">
<s_list_rep>
<li>
<a href="" class="link_thumb">
<s_list_rep_thumbnail>
<div class="youtube-container" data-url=""></div>
<div class="box_thumb thumb_img" style="background-image:url('//i1.daumcdn.net/thumb/C300x200.fwebp.q85/?fname='); display: none;"></div>
<div class="box_thumb no_img" style="display:none;"></div>
</s_list_rep_thumbnail>
<div class="cont_thumb">
<p class="txt_thumb"></p>
<p class="thumb_info">
<span class="date"></span>
<span class="name">by </span>
</p>
</div>
</a>
</li>
</s_list_rep>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</s_list>
2. ํฐ์คํ ๋ฆฌ ๋์์ ์คํฌ๋ฆฝํธ ์ฌ์ฉ
ํฐ์คํ ๋ฆฌ์์๋ ์๋ ์ฝ๋๋ฅผ ์ฌ์ฉํ๋ฉด ์ ํ๋ธ ๋์์ ์ ์ฝ๊ฒ, ์ฌ์ฉํ ์ ์์ต๋๋ค. ์ด๋ฏธ์ง์ ๋์์์ ๊ตฌ๋ถํด์ ๋์์ ๋งํฌ๊ฐ ์๋ ๊ฒฝ์ฐ๋ ์๋์ผ๋ก ์นดํ ๊ณ ๋ฆฌ ํ์ด์ง์ ์ฌ๋ค์์ ์๋ ๋ ธ์ถ์ด ๋ฉ๋๋ค. ๋ํ ๋์์์ด ์๋ ๊ฒฝ์ฐ๋ ์ด๋ฏธ์ง๊ฐ ๋ ธ์ถ๋ฉ๋๋ค.
<script>
document.addEventListener("DOMContentLoaded", function() {
const items = document.querySelectorAll('.youtube-container');
items.forEach(container => {
const url = container.dataset.url;
loadYoutubeUrl(url, container);
});
});
function loadYoutubeUrl(url, container) {
fetch(url)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.text();
})
.then(data => {
const parser = new DOMParser();
const doc = parser.parseFromString(data, 'text/html');
const youtubeUrlElement = doc.querySelector('p.youtubeurl');
const youtubeUrl = youtubeUrlElement ? youtubeUrlElement.textContent.trim() : null;
container.innerHTML = '';
const youtubeMatch = youtubeUrl ? youtubeUrl.match(/(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^&]{11})/) : null;
if (youtubeMatch) {
const youtubeId = youtubeMatch[1];
const youtubeEmbedUrl = `https://www.youtube.com/embed/${youtubeId}`;
const videoContainer = document.createElement('iframe');
videoContainer.src = youtubeEmbedUrl;
videoContainer.frameBorder = "0";
videoContainer.allow = "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture";
videoContainer.allowFullscreen = true;
videoContainer.title = "fpv-openipc";
container.appendChild(videoContainer);
const thumbnailImage = container.closest('.link_thumb').querySelector('.box_thumb.thumb_img');
thumbnailImage.style.display = 'none';
} else {
const thumbnailImage = container.closest('.link_thumb').querySelector('.box_thumb.thumb_img');
thumbnailImage.style.display = 'block';
container.style.display = 'none';
}
})
.catch(error => {
console.error('Error fetching the page:', error);
});
}
</script>
3. CSS๋ก ๋์์ ๋์์ธ
๋์์์ ๋ธ๋ก๊ทธ์ ์ฝ์ ํ ๋, CSS ์คํ์ผ์ ์ถ๊ฐํ๋ฉด ๋์์ ํ๋ ์ด์ด์ ํฌ๊ธฐ๋ ์์น๋ฅผ ์ต์ ํํ ์ ์์ต๋๋ค. ํนํ, ๋ฐ์ํ ๋์์ธ์ ์ ์ฉํ์ฌ ๋ชจ๋ฐ์ผ์์๋ ๋ฌธ์ ์์ด ๋์์์ด ์ ๋ณด์ด๋๋ก ํ ์ ์์ต๋๋ค.
<style>
.youtube-container {
position: relative;
width: 100%;
padding-top: 56.25%;
overflow: hidden;
}
.youtube-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
</style>
๋ธ๋ก๊ทธ์ ๋์์์ ํจ๊ณผ์ ์ผ๋ก ํตํฉํ๋ ๊ฒ์ ์ด์ ํ์๊ฐ ๋์์ต๋๋ค.
ํนํ, ๋์์ ์ฝํ ์ธ ๋ ๋ ์์ ๊ด์ฌ์ ๋๊ณ , ๋ธ๋ก๊ทธ์ ๋ฐฉ๋ฌธํ ์ฌ๋๋ค์๊ฒ ๋ ๋ง์ ๊ด์ฌ๋ฅผ ๋ง๋ค์ ์๋ ๊ฐ๋ ฅํ ๋๊ตฌ์ ๋๋ค. ํฐ์คํ ๋ฆฌ ์คํจ์ ์์ ํ๊ณ ๋์์์ ์ ๋ฐฐ์นํจ์ผ๋ก์จ, ๋ฐฉ๋ฌธ์๋ค์๊ฒ ๋์ฑ ํ์ฑํ๊ณ ๋ค์ฑ๋ก์ด ์ฝํ ์ธ ๋ฅผ ์ ๊ณตํ ์ ์์ต๋๋ค.
๋์์๊ณผ ํ ์คํธ๊ฐ ์ด์ฐ๋ฌ์ง๋ ๋ธ๋ก๊ทธ๋ ๋งค๋ ฅ์ ์ด๊ณ , ๋ ์๋ค์๊ฒ ๋ ๋ง์ ์ ๋ณด๋ฅผ ํจ๊ณผ์ ์ผ๋ก ์ ๋ฌํ๊ฒ ๋ ๊ฒ์ ๋๋ค.