/
single-sp_project.php
133 lines (117 loc) · 4.57 KB
/
single-sp_project.php
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
get_header();
?>
<section class="project-hero">
<div class="vimeo-iframe">
<?php
$videos = get_field('videos');
$first_vid = 0;
if( $videos )
$first_vid = $videos[0];
// This is a repeater field so its returning array
// (it has a max length of 1 video)
$hero_video = get_field('hero_video');
if( $hero_video ) {
$first_vid = $hero_video[0];
}
if( $first_vid ) : ?>
<iframe src="https://player.vimeo.com/video/<?php echo $first_vid['vimeo_id'] ?>?api=1" width="<?php echo $first_vid['video_w'] ?>" height="<?php echo $first_vid['video_h'] ?>" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<?php
elseif ( get_field('hero_image') ) :
$image = get_field('hero_image');
?>
<img src="<?php echo $image['url']; ?>">
<?php
endif;
?>
</div>
</section>
<section>
<div class="project-blurb">
<div class="project-blurb-col1">
<h2 class="client"><?php the_field('client'); ?></h2>
<h2 class="project"><a href="<?php the_permalink(); ?>" alt="<?php the_title(); ?>"><?php the_field('project_name'); ?></a></h2>
<div class="blurb"><?php the_field('project_information'); ?></div>
</div>
<div class="project-blurb-col2">
<h4>Tags</h4>
<div class="tags">
<?php project_tags(); ?>
</div>
<?php project_credits(); ?>
</div>
</div>
</section>
<?php if ( get_field('videos') ) : ?>
<section class="videos">
<?php project_videos(); ?>
</section>
<?php endif; ?>
<?php if( have_rows('sections') ): ?>
<?php while( have_rows('sections') ): the_row(); ?>
<section class="project-photos">
<h3><?php the_sub_field('title'); ?></h3>
<div class="project-masonry">
<?php
if ( get_sub_field('use_new_media') ) :
if ( have_rows("media") ):
$count = 0;
while ( have_rows("media") ): the_row();
$full_width = get_sub_field('full_width')? 'full-width' : '';
$is_video = get_row_layout() === 'video';
if( $is_video ) :
$image = get_sub_field('thumb');
ob_start(); ?>
<div class="vimeo-iframe">
<iframe src="https://player.vimeo.com/video/<?php the_sub_field('vimeo_id') ?>?api=1" width="<?php the_sub_field('video_w') ?>" height="<?php the_sub_field('video_h') ?>" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
<?php
$masonry_elem = ob_get_contents();
ob_end_clean();
elseif ( get_row_layout() === 'image' ) :
$image = get_sub_field('image');
ob_start();
lazy_image( $image['url'], $image['width'], $image['height'] );
$masonry_elem = ob_get_contents();
ob_end_clean();
endif;
$classes = [
"masonry-element-". ++$count,
$full_width,
$is_video? 'video-thumb' : ''
];
if ( $count === 1 && $full_width === 'full-width' ) { ?>
<div class="project-masonry-element masonry-element <?php echo "masonry-element-". $count ?>">
</div>
<?php
$classes = [
"masonry-element-". ++$count,
$full_width,
$is_video? 'video-thumb' : ''
];
}
?>
<div class="project-masonry-element masonry-element <?php echo join($classes, ' ') ?>">
<?php echo $masonry_elem ?>
</div>
<?php endwhile; endif;
else:
$images = get_sub_field('images');
foreach ( $images as $count => $image ): ?>
<div class="project-masonry-element masonry-element masonry-element-<?php echo $count+1; ?>">
<?php lazy_image( $image['url'], $image['width'], $image['height'] ); ?>
</div>
<?php endforeach;
endif;
?>
</div> <!-- .project-masonry -->
</section>
<?php endwhile; ?>
<?php endif; ?>
<?php
$related_projects = get_field('related_projects');
related_projects( $related_projects );
?>
<?php
get_footer();
?>