From 64bedf42ad229ed6508b0f4007fd4b3930f2a1fe Mon Sep 17 00:00:00 2001 From: Laury GvR Date: Fri, 9 Mar 2018 13:09:24 -0500 Subject: [PATCH] Differently sized featured image for member detail Jodie asked to make those pages have closer to 300px tall featured images --- functions.php | 46 ++++++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/functions.php b/functions.php index 4526308..0bfe9d8 100644 --- a/functions.php +++ b/functions.php @@ -117,31 +117,45 @@ function glm_get_header() { echo ''; } else { echo 'post_type == 'page') || is_page('member-detail')) { + // If Member detail + if(!$memberID){ + // If member detail but no member ID provided $image_data = wp_get_attachment_image_src(get_post_thumbnail_id(), "full"); + if ($image_data[0]) { + // If member detail, no member ID, and a featured image assigned in wp + $image_data = $image_data[0]; + echo ' style="background-image: url('.$image_data.');height:0;padding:0;padding-bottom:16%;background-position:center center;background-size: 100%;background-repeat:no-repeat;max-height: 300px; "'; + + } else { + // If member detail, no member ID, and no featured image assigned in wp + echo ' style="background-image: url('.get_template_directory_uri().'/assets/default-header.jpg?v=1.0);height:0;padding:0;padding-bottom:16%;background-position:center center;background-size: 100%;background-repeat:no-repeat;max-height: 300px;"'; + echo ' class="featured-image no-featured"'; + } + + } else { + // If member detail and a member ID provided + $image_data = apply_filters('member_images',$memberID,true,'original'); + echo ' style="background-image: url('.$image_data.');height:0;padding:0;padding-bottom:16%;background-position:center center;background-size: 100%;background-repeat:no-repeat;max-height: 300px; "'; + } + + + } else if (has_post_thumbnail() && !is_post_type('post') && !is_home()) { + // If not member detail, have thumbnail, but isn't single post or blog home + $image_data = wp_get_attachment_image_src(get_post_thumbnail_id(), "full"); echo ' style="background-image: url('.$image_data[0].');height:0;padding:0;padding-bottom:30%;background-position:center center;background-size: 100%;background-repeat:no-repeat;max-height: 300px; "'; - echo ' class="featured-image no-featured"'; + echo ' class="featured-image no-featured"'; } else { - echo ' style="background-image: url('.get_template_directory_uri().'/assets/default-header.jpg?v=1.0);height:0;padding:0;padding-bottom:30%;background-position:center center;background-size: 100%;background-repeat:no-repeat;max-height: 300px;"'; - echo ' class="featured-image no-featured"'; + // If not member detail, and either no thumbnail, or is single post, or is blog home + echo ' style="background-image: url('.get_template_directory_uri().'/assets/default-header.jpg?v=1.0);height:0;padding:0;padding-bottom:30%;background-position:center center;background-size: 100%;background-repeat:no-repeat;max-height: 300px;"'; + echo ' class="featured-image no-featured"'; } echo '>'; echo ''; } } -// // The code below is useful when you want the image to resize to -// if (has_post_thumbnail()) { -// $image_data = wp_get_attachment_image_src(get_post_thumbnail_id(), "full"); -// echo ''; -// } else { -// echo ''; -// } -// echo '
'; -// echo '
'; -// echo '
'; -// echo '
'; - add_action('wp_enqueue_scripts', 'glm_site_scripts'); -- 2.17.1