-
-
Save jamiemitchell/647da62bbe0f5a1a324d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Adding option to use featured image (if it exists) | |
| // in place of background image | |
| remove_action( 'genesis_after_header', 'beautiful_site_header_banner'); // removes existing banner image | |
| add_image_size( 'featured-banner', 2000, 200, TRUE ); // creates a featured image size for the banner | |
| function amcs_featured_img() { | |
| if ( has_post_thumbnail() ) { // checks post has thumbnail | |
| // gets URL for that image | |
| $background = wp_get_attachment_image_src( get_post_thumbnail_id( $page->ID ), 'featured-banner' ); | |
| if (is_array($background)) { | |
| // thanks to @magicroundabout for the fix | |
| // echo the output | |
| echo '<div class="featured-header-banner" style="background: url(' ; | |
| echo $background[0]; | |
| echo ') no-repeat scroll center center #FFFFFF"></div>'; | |
| }} | |
| else { // if no featured image, adds class to use existing banner | |
| echo '<div class="site-header-banner"></div>'; | |
| }} | |
| add_action( 'genesis_after_header', 'amcs_featured_img' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment