0

@Howdy_McGee helped me sort out adding a banner image to page_for_posts, however I need to resize images showing up in the blogroll for page_for_posts so it doesn't use the featured image banner because it's too wide. Codex states I use <?php add_image_size( $name, $width, $height, $crop ); ?> to resize an image specifically for this. However I'm not a php expert hoping someone could help point me in the right direction on how/where to add this. Here's my current code below. Thanks!

//* Add Header Images on Posts/Pages
add_image_size( 'header-img', 1600 );
add_action( 'genesis_after_header', 'site_banner', 0 );
function site_banner() {
if( ( is_page() || is_home() || is_single() )  ) {
    $post_id = ( is_home() ? get_option( 'page_for_posts' ) : get_the_ID() );

    if( has_post_thumbnail( $post_id ) ) {
        $ftbanner = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'header-img' );
        $banner = $ftbanner[0];
        echo '<div id="site-banner" class="site-banner">' . "\n";
        echo '<img src="' . $banner . '">' . "\n";
        echo '</div>' . "\n";
    }
}
}
0

Just had to register a new image size for a medium image with $crop. It's the simple things!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.