This repository has been archived by the owner on Aug 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 54
/
custom-header.php
50 lines (49 loc) · 2.03 KB
/
custom-header.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
<?php
/**
* This is the template part for the header image
*
* What it does is simple, yet clever:
* If you have custom-header support on, it will
* check if you have a global header image, if you
* don't but have a featured image big enough on your
* page or post, it will display that. Else it will
* display nothing.
*
* @since required+ Foundation 0.5.0
*/
?>
<!-- START: custom-header.php -->
<?php $header_image = get_header_image();
// So we have a header image, nice!
if ( $header_image ) {
?>
<a class="header-image" href="<?php echo esc_url( home_url( '/' ) ); ?>">
<?php
// If we have a thumbnail, we go for that.
if ( is_singular() && has_post_thumbnail( $post->ID ) ) {
// Houston, we have a new header image!
echo get_the_post_thumbnail( $post->ID, 'large-feature' );
// Let's go with the header image
} else {
?>
<img src="<?php header_image(); ?>" alt="" />
<?php
}
?>
</a>
<hr />
<?php
// So there was no header image, but we still have a nice thumbnail, right?
} else if ( is_singular() && has_post_thumbnail( $post->ID ) ) {
?>
<a class="header-image" href="<?php echo esc_url( home_url( '/' ) ); ?>">
<?php
// Houston, we have a new header image!
echo get_the_post_thumbnail( $post->ID, 'large-feature' );
?>
</a>
<hr />
<?php
}
?>
<!-- END: custom-header.php -->