2022/5/25:調整文字說明
在網頁嵌入影片請勿使用YouTube提供之嵌入語法:
原因
解決方法
請先找到影片的ID:
把影片的ID放進以下語法的「影片的ID」:
<style>.embed-container { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; max-width: 100%; } .embed-container iframe, .embed-container object, .embed-container embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }</style><div class='embed-container'><iframe width='560' height='315' src='https://www.youtube-nocookie.com/embed/影片的ID?rel=0' frameborder='0' allow='accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture' allowfullscreen></iframe></div>
放進「影片的ID」後的語法:
<style>.embed-container { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; max-width: 100%; } .embed-container iframe, .embed-container object, .embed-container embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }</style><div class='embed-container'><iframe width='560' height='315' src='https://www.youtube-nocookie.com/embed/SzvVIYW3CH0?rel=0' frameborder='0' allow='accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture' allowfullscreen></iframe></div>
把語法貼到網頁後台:
成果
Q&A
Q1:我想做進階設定
A1:請參考Google提供的「YouTube播放器演示」。
Q2:影片ID後面的「?rel=0」是做什麼用的?可以刪掉嗎?
A2:因在影片的ID後加入「?rel=0」,故只會顯示該頻道的影片,不會顯示其他頻道的影片。若沒有設定「?rel=0」,則影片結束時會根據用戶過去看影片的喜好放推薦影片,讓使用者感覺推薦影片與本校無關。(以前可以用「?rel=0」關掉結束畫面的推薦影片,但2018年9月起被Google改掉了)
Q3:使用這語法時,怎麼有些影片在左右有黑邊
A3:若您的影片是很久以前拍的4:3影片,用這語法嵌入時,影片左右有黑邊是正常狀況
Q4:我想在網站首頁嵌入YouTube影片
A4:請依照下列步驟
實作範例-使用響應式語法:
對照組:使用YouTube提供之嵌入語法
回到「校園網頁管理」看更多網頁管理說明