Summary Block Vimeo Popup

I released new code with better options. You can follow new instruction here.

Description

Click item in Summary Block (Summary Block pulls content from Video Page)

Plugin13 1

will open Youtube Video in Lightbox

Plugin14 1

#1. Install code

Click Gear icon on Page (where you use Summary Block)

Plugin13 3

Click Advanced > Paste this code

<!-- Summary Vimeo Popup @tuanphan -->
<style>.video-lightbox{display:none;position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.9);z-index:9999;align-items:center;justify-content:center}.video-lightbox.active{display:flex}.video-lightbox-content{position:relative;width:90%;max-width:1200px}.video-lightbox-iframe{position:relative;width:100%;padding-bottom:56.25%;height:0}.video-lightbox-close{position:absolute;top:-40px;right:0;background:none;border:none;color:#fff;font-size:32px;cursor:pointer;padding:0;width:40px;height:40px;line-height:1}.video-lightbox iframe{position:absolute;top:0;left:0;width:100%;height:100%;border:none}</style><script>document.addEventListener("DOMContentLoaded",function(){const e=document.createElement("div");e.className="video-lightbox",e.innerHTML='<div class="video-lightbox-content"><button class="video-lightbox-close">&times;</button><div class="video-lightbox-iframe"></div></div>',document.body.appendChild(e);const t=e.querySelector(".video-lightbox-close"),i=e.querySelector(".video-lightbox-iframe");t.addEventListener("click",function(){e.classList.remove("active"),i.innerHTML=""}),e.addEventListener("click",function(t){t.target===e&&(e.classList.remove("active"),i.innerHTML="")}),document.addEventListener("click",function(t){const n=t.target.closest('a[href*="/v/"]');if(n&&n.closest(".summary-block-wrapper")){t.preventDefault();const c=n.getAttribute("href")+"?format=json";fetch(c).then(e=>e.json()).then(t=>{const n=t.item?.items?.[0]?.oembed?.url;if(n){const t=n.match(/(?:vimeo\.com\/)(\d+)/)?.[1];t&&(i.innerHTML=`<iframe src="https://player.vimeo.com/video/${t}?autoplay=1" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe>`,e.classList.add("active"))}}).catch(e=>console.error("Error:",e))}})});</script>

Plugin15 1

#2. Usage

First, make sure you added Video in Video Page, use Vimeo Link

Plugin15 2

Make sure Summary Block pulls content from Video Page

Plugin13 6

Buy me a coffee