0
在我的WordPress插件中,我需要一個LightBox樣式的彈出窗口才能打開並播放YouTube視頻。該插件具有自定義帖子類型,用戶已經提供了一個保存爲post_meta的YouTube網址。在WordPress插件中的Lightbox中播放YouTube視頻
我有一個縮略圖的視頻,並認爲我可以創建一個與oembed函數的彈出鏈接,但顯然這並沒有幫助。不知道從這裏進行的最佳途徑是什麼。
編輯:通過評論
// Get the URL of the video
$wdm_youtube = get_post_meta($wdm_auction->ID, 'wdm_youtube', true);
if ($wdm_youtube != '') {
// Get the video ID
preg_match('#(?<=(?:v|i)=)[a-zA-Z0-9-_]+|(?<=(?:v|i)\/)[^&?\n]+|(?<=embed\/)[^"&?\n]+|(?<=(?:v|i)=)[^&?\n]+|(?<=youtu.be\/)[^&?\n]+#', $wdm_youtube, $matches);
if (!empty($matches)) {
// This gives an iframe link
$link = wp_oembed_get('https://www.youtube.com/watch?v=' . $matches[0]);
// main-img-a is for a local old lightbox lib that came with a plugin, no docs or link known
// All this code does is opens a larger image in a lightbox, no video
echo '<a class="main-img-a" href="http://i1.ytimg.com/vi/' . $matches[0] . '/sddefault.jpg">';
echo '<img id="wdm_youtube_image" src="http://i1.ytimg.com/vi/' . $matches[0] . '/hqdefault.jpg" />';
echo '</a>';
}
}
你可以發佈你試圖達到這個目標的代碼嗎? – adi
我已更新,但我覺得它阻礙,而不是幫助。我無法使用已安裝的代碼與安裝的LightBox庫一起工作,並希望獲得有關如何獲取以及如何使用更新的LightBox庫的建議。 –