Simple PHP scripts for daily use
Last active
October 19, 2023 01:37
-
-
Save haze83/531bd37fc1d11e4b73764cab7aac9628 to your computer and use it in GitHub Desktop.
PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$date = new \DateTime(strtotime(time())); | |
$date->setTimezone(new DateTimeZone('Europe/Zurich')); | |
$timestamp = $date->format('U'); | |
$date = $date->format('d.m.Y H:i:s'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$vimeo_id = '7489251' | |
$vimeo_url = 'https://player.vimeo.com/video/' . $vimeo_id; | |
$oembed_url = 'https://vimeo.com/api/oembed.json?url='. urlencode($vimeo_url); | |
$oembed_content = @file_get_contents($oembed_url); | |
if($oembed_content !== false) { | |
$oembed = json_decode($oembed_content); | |
$aspect_ratio_height = 100 / $oembed->width * $oembed->height; | |
} else { | |
$aspect_ratio_height = 56.25; // 16:9 | |
} | |
?> | |
<div class="aspect-ratio-container" style="padding-top: <?php echo $aspect_ratio_height; ?>%;"> | |
<iframe class="aspect-ratio-content" src="<?php echo $vimeo_url; ?>" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> | |
</div> | |
<style> | |
.aspect-ratio-container { | |
position: relative; | |
} | |
.aspect-ratio-content { | |
display: block; | |
position: absolute; | |
top: 0; | |
right: 0; | |
bottom: 0; | |
left: 0; | |
width: 100%; | |
height: 100%; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment