សួស្ដីអ្នកទាំងអស់គ្នា ថ្ងៃនេះខ្ញុំសូមបង្ហាញពីរបៀប Embed វីដេអូពីវេបសាយផ្សេងៗដូចជា៖ Dailymotion, Google Drive, Odnoklassniki ( ok.ru ), Vimeo, Youtube... លើសពីនេះទៅទៀតអ្នកគ្រាន់តែប្រើប្រាស់កូដមួយបន្ទាត់ប៉ុណ្ណោះក្នុងការ Post ដើម្បីអោយវីដេអូបង្ហាញ តោះ! កុំចាំយូររៀនតម្លើងជាមួយខ្ញុំនៅខាងក្រោម។
១.ចូលទៅកាន់ Theme ចុចសញ្ញា ▼ រួចយកពាក្យ Edit HTML
២.ចម្លងកូដខាងក្រោមដាក់ពីខាងលើ </b:skin>
.embed-container {
position: relative;
width: 100%;
height: 100%;
padding-top: 56.25%;
overflow: hidden;
background: #000000;
border: 4px solid #8000ff;
border-radius: 4px;
}
.embed-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 0;
}
៣.ចម្លងកូដខាងក្រោមដាក់ពីខាងលើ </body><script type="text/javascript">
//<![CDATA[
class RSTVideoEmbed {
constructor(element, options = {}) {
this.playerElement = document.getElementById(element);
this.options = {
autoplay: false,
...options
};
}
removeAttributes() {
const attributes = Array.from(this.playerElement.attributes);
attributes.forEach(attribute => {
if (attribute.name !== "id") {
this.playerElement.removeAttribute(attribute.name);
}
});
}
init() {
if (this.playerElement) {
const videoId = this.playerElement.dataset.id;
const videoUrl = this.playerElement.dataset.url;
const provider = this.playerElement.getAttribute("provider");
const isAutoplay = this.options.autoplay ? "?autoplay=1" : "";
const getProviders = {
dailymotion: `https://www.dailymotion.com/embed/video/${videoId}${isAutoplay}`,
googledrive: `https://drive.google.com/file/d/${videoId}/preview`,
ok: `https://ok.ru/videoembed/${videoId}${isAutoplay}`,
vimeo: `https://player.vimeo.com/video/${videoId}${isAutoplay}`,
youtube: `https://www.youtube.com/embed/${videoId}${isAutoplay}`
};
const url = getProviders[provider] || `${videoUrl || "about:blank"}`;
let okReferrer = '';
if (window.location.href.includes(".blogspot.com") && provider === "ok") {
okReferrer = ` referrerpolicy="no-referrer"`;
}
this.playerElement.innerHTML = `<div class="embed-container"><iframe src="${url}" width="100%" height="100%" allow="autoplay; fullscreen"${okReferrer} loading="lazy"></iframe></div>`;
this.removeAttributes();
}
}
static render(element, options) {
return new RSTVideoEmbed(element, options).init();
}
}
RSTVideoEmbed.render("embed-player", {
autoplay: true
});
//]]>
</script>
៤.ចុច Icon Save រួចចាកចេញពីផ្ទាំង Edit HTML៥.ជ្រើសរើសកូដណាមួយខាងក្រោម ដាក់ចូលទៅកាន់ Blog Post (HTML View)
<div id="embed-player" data-id="x8fk3rq" provider="dailymotion"></div>
<div id="embed-player" data-id="0Bwh7cTp2lB3PRmgtODRWOENEb28" provider="googledrive"></div>
<div id="embed-player" data-id="4782018661043" provider="ok"></div>
<div id="embed-player" data-id="208621116" provider="vimeo"></div>
<div id="embed-player" data-id="nAvDh3to9oY" provider="youtube"></div>
<div id="embed-player" data-url="https://rumble.com/embed/v3ccruu"></div>