Community Forums › Forums › Archived Forums › General Discussion › Problem with Featured Images in Going-Green
Tagged: Featured Images "Going Green"
- This topic has 6 replies, 3 voices, and was last updated 10 years, 7 months ago by gfalken.
-
AuthorPosts
-
August 26, 2013 at 8:38 am #58858bigfishParticipant
I know this topic has been covered several times before, but the solutions don't seem to exist in the functions.php file I downloaded with the theme, so I'm not sure if it was updated for recent downloads.
Anyway, I am seeing an image show up before the headline of my posts. This is fine if I select a "Featured Image" but if I don't select an image to be featured, the theme is selecting a random image in the post and displaying it (again) above the headline. I don't want any image to be shown up there.
For example, here's a page that is wrong: http://coolandcollected.com/original-frank-miller-dark-knight-cover-art-sells-for-478000/
There should not be an image above the headline. No images were selected as "Featured Image."
The functions.php that came with the theme has this code:
//* Add featured image above the entry content
add_action( 'genesis_entry_header', 'going_green_featured_photo', 5 );
function going_green_featured_photo() {
if ( is_page() || ! genesis_get_option( 'content_archive_thumbnail' ) )
return;if ( $image = genesis_get_image( array( 'format' => 'url', 'size' => genesis_get_option( 'image_size' ) ) ) ) {
printf( '<div class="featured-image"></div>', $image, the_title_attribute( 'echo=0' ) );
}
}I'm sure there's a simple solution to this, but I just don't know it! Thanks in advance.
August 31, 2013 at 4:56 am #59864Sridhar KatakamParticipantCan you paste the full code present in child theme's functions.php at http://www.pastebin.com and give us a link?
September 5, 2013 at 8:15 am #60832bigfishParticipantHere's a link to the entire functions.php
September 5, 2013 at 9:21 am #60848Sridhar KatakamParticipantTry deleting
//* Remove default post image remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 ); //* Add featured image above the entry content add_action( 'genesis_entry_header', 'going_green_featured_photo', 5 ); function going_green_featured_photo() { if ( is_page() || ! genesis_get_option( 'content_archive_thumbnail' ) ) return; if ( $image = genesis_get_image( array( 'format' => 'url', 'size' => genesis_get_option( 'image_size' ) ) ) ) { printf( '<div class="featured-image"><img src="%s" alt="%s" /></div>', $image, the_title_attribute( 'echo=0' ) ); } }
September 5, 2013 at 10:00 am #60857bigfishParticipantRemoving that bit of code did remove the featured image from appearing above the headline, but that's not exactly what I was hoping for.
I want the featured image to appear above the headline IF there is a selected feature image. If there is no feature image selected within a post, there should not be an image appearing above the headline. The original code seems to select an image from the post to use as the featured image, which results in the same image appearing twice, once above the headline and second time within the post, as it should.
September 5, 2013 at 10:43 am #60877Sridhar KatakamParticipant<?php if (has_post_thumbnail()) { ?> <div class="my-featured-image"> <?php the_post_thumbnail('my-featured-image'); ?> </div> <?php } ?>
is a generic code that will check for the presence of post thumbnail and if present, display it. 'my-featured-image' would be the image size that can be defined via add_image_size().
In http://pastebin.com/giJSHmmw try replacing
if ( $image = genesis_get_image( array( 'format' => 'url', 'size' => genesis_get_option( 'image_size' ) ) ) ) { printf( '<div class="featured-image"><img src="%s" alt="%s" /></div>', $image, the_title_attribute( 'echo=0' ) ); }
with the above code.
September 14, 2013 at 1:13 pm #62553gfalkenMemberI fixed this by changing the first IF statement in function going_green_featured_photo() to
if ( ! has_post_thumbnail() || (is_page() || ! genesis_get_option( 'content_archive_thumbnail' )) ) return;
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.