شرح طريقة أظهار الفيديوهات بشكل سلايدر بداخل الموضوع لقوالب بلوجر
ان كان لديك موضوع و به عدة فيديوهات هذه الاضافة مناسبة لك و هي تجعل الفيديوهات تظهر بشكل سلايدر بدلا من ان يكون عدة فيديوهات كثيرة و متناثرة بالموضوععرض منظم وجذاب
بدل ما تحط الفيديوهات واحد تحت الثاني بشكل طويل وممل، السلايدر يخليها مرتبة في مساحة صغيرة مع إمكانية التصفح بينها.
زيادة التفاعل
القارئ يقدر يتنقل بين الفيديوهات بسهولة بالأسهم أو السحب (لو ضفت لمسة موبايل)، وده يخليه يقضي وقت أطول على الصفحة.
- تحسين تجربة المستخدم (UX)
- على الكمبيوتر: يكون الشكل احترافي ومنظم.
- على الموبايل: السلايدر يوفر مساحة كبيرة ويخلي التصفح أسهل.
- شرح سلسلة دروس (الفيديو 1، 2، 3 …).
- مقارنات بين منتجات (فيديو لموبايل X وفيديو لموبايل Y).
- تجميع فيديوهات حول نفس الفكرة.
- جاذبية بصرية (Visual Appeal)
- شكل السلايدر يعطي لموضوعك لمسة احترافية زي المواقع الكبيرة، بدل من مجرد روابط أو فيديوهات مبعثرة.
- تحسين الـ SEO بشكل غير مباشر
شرح طريقة تركيب أداة عرض الفيديوهات بشكل سلايدر
الأكواد الخاصة بالأداة
نذهب الى اكواد القالب اللذي نلايد استخدام الاداة عليه و نبحث عن </body> و نلصق الاكواد التالية اعلاها
<style>.video-slider {width: 100%;max-width: 900px;margin: 40px auto;position: relative;border-radius: 8px;overflow: hidden;}.video-container {position: absolute;width: 100%;height: 100%;opacity: 0;transition: opacity 0.7s ease;pointer-events: none;}.video-container.active {position: relative;padding-bottom: 56.25%;height: 0;opacity: 1;pointer-events: auto;}.video-container iframe {position: absolute;top: 0;left: 0;width: 100%;height: 100%;}.slider-button {position: absolute;top: 50%;transform: translateY(-50%);z-index: 10;background-color: rgba(0,0,0,0.5);border: none;color: #fff;padding: 6px 12px;font-size: 18px;cursor: pointer;border-radius: 4px;user-select: none;}#prevBtn { left: 10px; }#nextBtn { right: 10px; }@media (max-width:480px){.slider-button { font-size: 16px; padding: 4px 8px; }}.floating-video {position: fixed;width: 320px;height: 180px;bottom: 20px;right: 20px;z-index: 9999;box-shadow: 0 4px 12px rgba(0,0,0,0.3);border-radius: 4px;}</style><script type='text/javascript'>//<![CDATA[document.addEventListener("DOMContentLoaded", function() {const containers = document.querySelectorAll('.video-container');const prevBtn = document.getElementById('prevBtn');const nextBtn = document.getElementById('nextBtn');let currentIndex = 0;let floatingVideo = null;function showVideo(index) {containers.forEach((c, i) => c.classList.toggle('active', i === index));currentIndex = index;updateFloating();}prevBtn.addEventListener('click', () => {const newIndex = (currentIndex - 1 + containers.length) % containers.length;showVideo(newIndex);});nextBtn.addEventListener('click', () => {const newIndex = (currentIndex + 1) % containers.length;showVideo(newIndex);});// --- Floating Video Functions ---function createFloating() {if (!floatingVideo) {const activeIframe = containers[currentIndex].querySelector('iframe');floatingVideo = activeIframe.cloneNode(true);floatingVideo.classList.add('floating-video');document.body.appendChild(floatingVideo);}}function updateFloating() {if (floatingVideo) {const activeIframe = containers[currentIndex].querySelector('iframe');floatingVideo.src = activeIframe.src;}}function removeFloating() {if (floatingVideo) {floatingVideo.remove();floatingVideo = null;}}// --- Scroll Listener ---window.addEventListener('scroll', () => {const rect = containers[currentIndex].getBoundingClientRect();if (rect.bottom < 0 || rect.top > window.innerHeight) {createFloating();} else {removeFloating();}});});//]]></script>
و نقوم بالحفظ
و الان اذا اردنا اضافة السلايدر لاي موضوع نذهب الى تعديل HTML و نضيف الاكواد في مكان مناسب
<div class="video-slider"><div class="video-container active"><iframe src="https://www.youtube.com/embed/y9ctE5Urxfc" frameborder="0" allowfullscreen></iframe></div><div class="video-container"><iframe src="https://www.youtube.com/embed/CdfqW83JaeM" frameborder="0" allowfullscreen></iframe></div><div class="video-container"><iframe src="https://www.youtube.com/embed/pLq8bQjhC18" frameborder="0" allowfullscreen></iframe></div><div class="video-container"><iframe src="https://www.youtube.com/embed/k1QcCsPJAOc" frameborder="0" allowfullscreen></iframe></div><button class="slider-button" id="prevBtn">←</button><button class="slider-button" id="nextBtn">→</button></div>
ملاحظة
ستجد بالاكواد كود باللون الاحمر و هو ال id الخاص بالفيديو يجب استبداله بـ id الفيديو اللذي تريد اضافته
تنبيه
اذا اردت زيادة عدد الفيديوهات اللتي تظهر بالاداة او تقليل عددها كل ما عليك ان تضيف او تحذف مثل هذا الكود بالكامل ستجده بهذا الشكل
<div class="video-container"><iframe src="https://www.youtube.com/embed/k1QcCsPJAOc" frameborder="0" allowfullscreen></iframe></div>
قم باضافة او احذف العدد اللذي تريده و ثم قم بالحفظ
و مبروك الاداة
شكرًا لوقتكم واهتمامكم بقراءة موضوع عرض الفيديوهات بشكل سلايدر داخل موضوعات بلوجر. إذا صادفتكم أي مشكلة أثناء استخدام الكود أو كان لديكم أي استفسار، فلا تترددوا في طرحه ضمن التعليقات أو التواصل معنا عبر صفحة الاتصال بنا . ولا تنسوا الانضمام إلى متابعي مدونة هلا تك ليصلكم كل كل ما هو جديد.