當插入fluidvids.js代碼之前視頻嵌入時,我無法讓fluidsvids.js在我的github頁面託管的網站(運行於Poole/Jekyll)上工作。爲什麼javascript(fluidvids.js)只能在*視頻嵌入後加載時才能工作?
但是,在之後插入代碼時,視頻會嵌入視頻,因爲fluidvids.js會將視頻調整爲佈局。 這是爲什麼?
我萃取整個fluidvids zip文件到/public/js/fluidvids
。
在我_includes
文件夾中,我創建了一個HTML文件,fluidvids.html
:
<!-- fluidvids.js -->
<script src="{{ site.baseurl }}public/js/fluidvids/dist/fluidvids.js"></script>
<script>
fluidvids.init({
selector: ['iframe'],
players: ['www.youtube.com', 'player.vimeo.com']
});
</script>
而且在我default.html
佈局,我插{% include fluidvids.html %}
:
<!DOCTYPE html>
<html lang="en-us">
{% include head.html %}
{% include google_analytics.html %}
<body>
{% include fluidvids.html %}
{% include sidebar.html %}
<div class="content container">
{{ content }}
</div>
</body>
</html>
最後,我的嵌入式測試的兩個視頻一個帖子; 2007-02-10-Island-of-Lost-Souls.md
:
<!DOCTYPE html>
<html lang="en-us">
{% include head.html %}
{% include google_analytics.html %}
<body>
{% include sidebar.html %}
<div class="content container">
{{ content }}
{% include fluidvids.html %}
</div>
</body>
</html>
這是爲什麼:
<iframe src="https://player.vimeo.com/video/9685584" width="500" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<iframe width="420" height="315" src="https://www.youtube.com/embed/ZdyzjKDWpYU" frameborder="0" allowfullscreen></iframe>
但是,影片沒有與佈局,直到我把包括博客文章的內容後,這樣的調整?
Here's呈現的帖子,當fluidvid.js加載後的博客文章內容。