added deferred youtuibe video block
This commit is contained in:
parent
f34cfd1bff
commit
6e8f0b0bb9
9 changed files with 63 additions and 33 deletions
19
blocks/deferred-youtube-video/render.php
Normal file
19
blocks/deferred-youtube-video/render.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* @see https://github.com/WordPress/gutenberg/blob/trunk/docs/reference-guides/block-api/block-metadata.md#render
|
||||
*/
|
||||
?>
|
||||
<div <?php echo get_block_wrapper_attributes(); ?> style="max-width:<?php echo $attributes['width'] ?>;height: auto; margin: 0 auto;">
|
||||
<div class="video-container">
|
||||
<img class="dyvideo-cover lazyload"
|
||||
loading="lazy"
|
||||
src="https://i.ytimg.com/vi_webp/<?php echo $attributes['url'] ?>/maxresdefault.webp">
|
||||
<iframe
|
||||
class="dyvideo-iframe"
|
||||
data-src="https://www.youtube.com/embed/<?php echo $attributes['url'] ?>?autoplay=0&rel=0">
|
||||
</iframe>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- srcdoc="<!DOCTYPE html><html><head><style>*{padding:0;margin:0;overflow:hidden}html,body{height:100%}img,span{position:absolute;width:100%;top:0;bottom:0;margin:auto}span{height:1.5em;text-align:center;font:48px/1.5 sans-serif;color:white;text-shadow:0 0 0.5em black;left:0}a{position:relative;display:block;}</style></head><body><a href='https://www.youtube.com/embed/<?php echo $attributes['url'] ?>?autoplay=1&rel=0&mute=1'><img src='https://img.youtube.com/vi/<?php echo $attributes['url'] ?>/maxresdefault.jpg' alt='Play Video' style='height:auto;width:100%;transform:translateX(-50%);position:relative;left:50%'><span>▶</span></a></body></html>"></iframe>
|
||||
-->
|
Loading…
Add table
Add a link
Reference in a new issue