Skip to content

Instantly share code, notes, and snippets.

@haze83
Last active October 19, 2023 01:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haze83/531bd37fc1d11e4b73764cab7aac9628 to your computer and use it in GitHub Desktop.
Save haze83/531bd37fc1d11e4b73764cab7aac9628 to your computer and use it in GitHub Desktop.
PHP

PHP

Simple PHP scripts for daily use

<?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');
<?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