Refactor blocks architecture to modular approach
- Restore "1/2, 1/2" layout for flexible column combinations - Simplify beforeafter block: remove toggle and text field, keep only image comparison - Create new video block with URL support (YouTube/Vimeo/direct files) - Create horizontal-gallery block for scrollable image galleries - Add H4 heading level support - All blocks now modular: combine with text blocks in 2-column layouts Blocks available: - Text, Heading (h2-h4), Image, Video - Before/After comparison (no text) - Horizontal gallery (with text below) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
6251d8f09f
commit
561932724b
23 changed files with 539 additions and 252 deletions
39
site/plugins/video/snippets/blocks/video.php
Normal file
39
site/plugins/video/snippets/blocks/video.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/** @var \Kirby\Cms\Block $block */
|
||||
$url = $block->url()->value();
|
||||
$caption = $block->caption()->value();
|
||||
|
||||
// Fonction pour détecter le type de vidéo
|
||||
function getVideoEmbedCode($url) {
|
||||
// YouTube
|
||||
if (preg_match('/youtube\.com\/watch\?v=([^&]+)/', $url, $matches) ||
|
||||
preg_match('/youtu\.be\/([^?]+)/', $url, $matches)) {
|
||||
$videoId = $matches[1];
|
||||
return '<iframe src="https://www.youtube.com/embed/' . $videoId . '" frameborder="0" allowfullscreen></iframe>';
|
||||
}
|
||||
|
||||
// Vimeo
|
||||
if (preg_match('/vimeo\.com\/(\d+)/', $url, $matches)) {
|
||||
$videoId = $matches[1];
|
||||
return '<iframe src="https://player.vimeo.com/video/' . $videoId . '" frameborder="0" allowfullscreen></iframe>';
|
||||
}
|
||||
|
||||
// Vidéo directe (mp4, webm, etc.)
|
||||
if (preg_match('/\.(mp4|webm|ogg)$/i', $url)) {
|
||||
return '<video controls><source src="' . $url . '" type="video/' . pathinfo($url, PATHINFO_EXTENSION) . '"></video>';
|
||||
}
|
||||
|
||||
// Par défaut, iframe
|
||||
return '<iframe src="' . $url . '" frameborder="0" allowfullscreen></iframe>';
|
||||
}
|
||||
?>
|
||||
|
||||
<?php if ($url): ?>
|
||||
<div class="container-video">
|
||||
<?= getVideoEmbedCode($url) ?>
|
||||
</div>
|
||||
|
||||
<?php if ($caption): ?>
|
||||
<p class="caption"><?= $caption ?></p>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue