adding new default image for pages
authorAnthony Talarico <talarico@gaslightmedia.com>
Tue, 16 May 2017 16:44:59 +0000 (12:44 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Tue, 16 May 2017 16:44:59 +0000 (12:44 -0400)
added a conditional to the functions file to set a new default page image if there is no featured image
set in post type pages

assets/Center-skinny-1.jpg [new file with mode: 0644]
functions.php

diff --git a/assets/Center-skinny-1.jpg b/assets/Center-skinny-1.jpg
new file mode 100644 (file)
index 0000000..d874288
Binary files /dev/null and b/assets/Center-skinny-1.jpg differ
index b4ae400..6cf6cc7 100644 (file)
@@ -83,10 +83,13 @@ function glm_get_header() {
     if (has_post_thumbnail() && is_post_type('page')) {
             $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:20%;background-position:top center;background-size: 100%;background-repeat:no-repeat;max-height: 300px;overflow-y: hidden; "';
-    } else {
+    } else if(is_post_type('post') ){
             echo ' style="background-image: url('.get_template_directory_uri().'/assets/News-header.png);height:0;padding:0;padding-bottom:20%;background-position:top center;background-size: 100%;background-repeat:no-repeat;max-height: 300px;overflow-y: hidden;"';
             echo ' class="no-featured"';
-    }
+    } else if(!has_post_thumbnail() && is_post_type('page')){
+         echo ' style="background-image: url('.get_template_directory_uri().'/assets/Center-skinny-1.jpg);height:0;padding:0;padding-bottom:20%;background-position:top center;background-size: 100%;background-repeat:no-repeat;max-height: 300px;overflow-y: hidden;"';
+            echo ' class="no-featured"';
+    } 
     echo '>';
     echo '</div>';
     echo '<div class="row">';