Differently sized featured image for member detail
authorLaury GvR <laury@gaslightmedia.com>
Fri, 9 Mar 2018 18:09:24 +0000 (13:09 -0500)
committerLaury GvR <laury@gaslightmedia.com>
Fri, 9 Mar 2018 18:09:24 +0000 (13:09 -0500)
Jodie asked to make those pages have closer to 300px tall featured
images

functions.php

index 4526308..0bfe9d8 100644 (file)
@@ -117,31 +117,45 @@ function glm_get_header() {
        echo '</div>';
     } else {
         echo '<div';
-        if (has_post_thumbnail() && !is_post_type('post') && !is_home()) {
+        
+        if ((has_post_thumbnail() && $post->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 '</div>';
     }
 }
 
-// // 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 '<img src="'.$image_data[0].'" style="no-repeat;max-height:400px;">';
-//    } else {
-//            echo '<img src="'.get_template_directory_uri().'/assets/default-header.gif" style="max-height:400px;">';
-//    }
-//    echo '<div class="row">';
-//    echo '<div class="small-12 columns">';
-//    echo '</div>';
-//    echo '</div>';
-
 add_action('wp_enqueue_scripts', 'glm_site_scripts');