init
This commit is contained in:
3
site/snippets/blocks/audio.php
Normal file
3
site/snippets/blocks/audio.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<?php foreach ($data->file()->toFiles() as $file): ?>
|
||||
<audio controls controlsList="nodownload" src="<?= $file->url() ?>" <?= $data->loop()->toBool() ? "loop" : "" ?>></audio>
|
||||
<?php endforeach ?>
|
||||
3
site/snippets/blocks/code.php
Normal file
3
site/snippets/blocks/code.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<?php if ($block->language() == "css"): ?>
|
||||
<style><?= $block->code()->value() ?></style>
|
||||
<?php endif; ?>
|
||||
52
site/snippets/blocks/embed.php
Normal file
52
site/snippets/blocks/embed.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php if ($embed = $data->embed()->toEmbed()): ?>
|
||||
<?php
|
||||
$biggestImage = $embed->image()->value();
|
||||
$biggestImageSize = 0;
|
||||
|
||||
$images = $embed->images()->value();
|
||||
|
||||
if ($images) {
|
||||
foreach ($images as $image) {
|
||||
$size = $image['width'] * $image['height'];
|
||||
if ($biggestImageSize < $size) {
|
||||
$biggestImageSize = $size;
|
||||
$biggestImage = $image['url'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$iframe = str_replace('src="', 'data-src="', $embed->code()->value());
|
||||
|
||||
if (
|
||||
$data->loop()->toBool() === true || true
|
||||
) {
|
||||
preg_match('/\?v=(.*)/', $embed->url()->value(), $m);
|
||||
if ($m) {
|
||||
$iframe = preg_replace('/data-src="(.+?)"/', "data-src=\"\$1&playlist={$m[1]}&loop=1\"", $iframe);
|
||||
}
|
||||
}
|
||||
|
||||
$btnClass = $embed->providerName()->value() === 'YouTube' ? 'yt' : '';
|
||||
?>
|
||||
|
||||
<?php if ($embed->providerName()->value() === 'thealit'): ?>
|
||||
<div class="embed">
|
||||
<?= $embed->code() ?>
|
||||
</div>
|
||||
<?php elseif ($embed->providerName()->value() === 'Mixcloud'): ?>
|
||||
<?= $embed->code()->value() ?>
|
||||
<?php else: ?>
|
||||
<div class="embed">
|
||||
<div class="iframe"><?= $iframe ?></div>
|
||||
|
||||
<div>
|
||||
<img src="<?= $biggestImage ?>" loading="lazy">
|
||||
<div class="embed-btn <?= $btnClass ?>"></div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ($data->text()->isNotEmpty()): ?>
|
||||
<div class="text-10"><?= $data->text()->html() ?></div>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
5
site/snippets/blocks/iframe.php
Normal file
5
site/snippets/blocks/iframe.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
/** @var \Kirby\Cms\Block $block */
|
||||
?>
|
||||
|
||||
<iframe class="iframe" src="<?= $block->url() ?>"></iframe>
|
||||
23
site/snippets/blocks/image.php
Normal file
23
site/snippets/blocks/image.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/** @var \Kirby\Cms\Block $block */
|
||||
$image = $block->image()->toFile();
|
||||
$alt = $block->alt() ?? $image->alt();
|
||||
$caption = $block->caption();
|
||||
$src = $image->url();
|
||||
?>
|
||||
<?php if ($src): ?>
|
||||
<?php if ($block->link()->isNotEmpty()): ?>
|
||||
<a href="<?= $block->link()->value() ?>">
|
||||
<?php endif ?>
|
||||
<figure>
|
||||
<img srcset="<?= $image->srcset('full') ?>" alt="<?= $alt->esc() ?>" loading="lazy">
|
||||
<?php if ($caption->isNotEmpty()): ?>
|
||||
<figcaption>
|
||||
<?= $caption ?>
|
||||
</figcaption>
|
||||
<?php endif ?>
|
||||
<?php if ($block->link()->isNotEmpty()): ?>
|
||||
</a>
|
||||
<?php endif ?>
|
||||
</figure>
|
||||
<?php endif ?>
|
||||
7
site/snippets/blocks/image_gallery.php
Normal file
7
site/snippets/blocks/image_gallery.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<div class="siema">
|
||||
<div class="siema-gallery">
|
||||
<?php foreach ($data->images()->toFiles() as $image): ?>
|
||||
<div><img srcset="<?= $image->srcset('full') ?>" loading="lazy"></div>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
</div>
|
||||
10
site/snippets/blocks/texts.php
Normal file
10
site/snippets/blocks/texts.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php /** @var \Kirby\Cms\Block $block */ ?>
|
||||
|
||||
<?php
|
||||
$centerHorizontal = $block->center_horizontal()->toBool();
|
||||
$centerVertical = $block->center_vertical()->toBool();
|
||||
?>
|
||||
|
||||
<div class="<?= $centerHorizontal ? "text-center" : "" ?> <?= $centerVertical ? "align-self-center" : "" ?>">
|
||||
<?= $block->text() ?>
|
||||
</div>
|
||||
17
site/snippets/blocks/twitch.php
Normal file
17
site/snippets/blocks/twitch.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
$id = uniqid('twitch');
|
||||
?>
|
||||
|
||||
<div>
|
||||
<div id="<?= $id ?>"></div>
|
||||
|
||||
<script src="https://player.twitch.tv/js/embed/v1.js"></script>
|
||||
|
||||
<script>
|
||||
new Twitch.Player("<?= $id ?>", {
|
||||
channel: "<?= $data->channel()->value() ?>",
|
||||
width: '100%',
|
||||
height: 480,
|
||||
})
|
||||
</script>
|
||||
</div>
|
||||
9
site/snippets/blocks/video.php
Normal file
9
site/snippets/blocks/video.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
$video = $data->file()->toFile();
|
||||
$poster = $data->poster()->toFile();
|
||||
$loop = $data->loop()->toBool();
|
||||
?>
|
||||
|
||||
<?php if ($video): ?>
|
||||
<video controls controlsList="nodownload" src="<?= $video->url() ?>" <?= $poster ? "poster=\"{$poster->url()}\"" : "" ?> <?= $loop ? "loop" : "" ?>></video>
|
||||
<?php endif ?>
|
||||
Reference in New Issue
Block a user