Last active
April 16, 2019 14:06
-
-
Save leepettijohn/6f51b9ab443296369329 to your computer and use it in GitHub Desktop.
Add image to top of pages and posts
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
add_image_size( 'featured-top', 750, 500, TRUE ); | |
add_action ('genesis_before_loop','add_top_image'); | |
function add_top_image(){ | |
if (is_page() || is_single()){ | |
the_post_thumbnail('featured-top',array('class'=>'top-of-post')); | |
} | |
} | |
// Use this one if it's full width and needs to be a background image | |
add_action('genesis_after_header','add_top_img',12); | |
function add_top_img(){ | |
if (is_page()){ | |
echo '<div class="top-image" style="background-image:url('; | |
the_post_thumbnail_url(); | |
echo ')"></div>'; | |
} | |
} |
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
.top-image { | |
width: 100%; | |
height: 255px; | |
background-size: cover; | |
background-position: center; | |
} | |
@media screen and (max-width:1023px){ | |
/* This includes 768px*/ | |
.top-image { | |
height: 200px; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
change 750 and 500 to correct dimensions