promo-area.php
1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
// Create id attribute allowing for custom "anchor" value.
$id = 'promo-area' . $block['id'] . rand(0,100);
if( !empty($block['anchor']) ) {
$id = $block['anchor'];
}
// Create class attribute allowing for custom "className" and "align" values.
$className = 'promo-area' ;
$className .= ' ' .get_field('style');
if( !empty($block['className']) ) {
$className .= ' ' . $block['className'];
}
$content = get_field('content');
$image = get_field('image');
$thumbnail_image = get_posts(array('p' => $image['ID'], 'post_type' => 'attachment'));
if ($thumbnail_image && isset($thumbnail_image[0])) {
$img_description = $thumbnail_image[0]->post_content;
$photo_caption = $thumbnail_image[0]->post_excerpt;
$img_alt = get_post_meta($image['ID'] , '_wp_attachment_image_alt', true);
$img_title = $thumbnail_image[0]->post_title;
$copy = get_field('copy', $image['ID'] );
}
?>
<div class="<?= $className ?>" id='<?= $id ?>'>
<div class='content'>
<?php echo $content; ?>
</div>
<div class='image' style="<?= (!empty($image))?"background-image: url(".$image['url'] .")":"" ?>">
<div class='side-caption header-caption <?= (empty($copy) && empty($cap)) ? "hide" : "" ?>'>
<a class='copy-link' aria-label="Header Slide Caption" href='#' ></a>
<span class='image-side-caption'>
<span class='cap'><?= $photo_caption ?></span>
<span class='copyright'><?= ($copy) ? "© ".$copy : "" ?></span>
</span>
</div>
</div>
</div>