Community Forums › Forums › Archived Forums › Design Tips and Tricks › Add featured Image To Posts
Tagged: Balance, featured image
- This topic has 10 replies, 3 voices, and was last updated 10 years, 3 months ago by
nathaniell.
-
AuthorPosts
-
December 6, 2014 at 1:58 pm #133843
nathaniell
ParticipantHi Guys,
I'm using the Balance child theme. I'm trying to add a featured image to my posts, as in this one here: http://brew7.com/do-you-really-need-a-5000-ml-erlenmeyer-flask/
I got the featured image working on the home page (http://brew7.com/) for the featured post, and basically want the same thing for the actual post.
I tried to use the code here: http://sridharkatakam.com/adding-featured-images-post-titles-minimum-pro/ but couldn't get it to work. The code I added to my theme so far is this:
//* Add new image sizes add_image_size('grid-thumbnail', 536, 150, TRUE); add_image_size('single-thumbnail', 720, 250, TRUE); add_action ( 'genesis_entry_header', 'sk_show_featured_image_single' ); function sk_show_featured_image_single() { if ( is_single() && has_post_thumbnail() ) { echo '<div class="single-thumbnail">'; genesis_image( array( 'size' => 'single-thumbnail' ) ); echo '</div>'; } }
I'm a beginner at this stuff. I can copy/paste without messing up my site, but as far as the actual code goes, I'm pretty lost.
Any suggestions or help is welcome!
http://brew7.comDecember 6, 2014 at 3:38 pm #133851anotherusername
ParticipantJust thinking out loud here...
I wonder if your theme has the genesis_entry_header hook on your single posts / pages or not...
I thought that hook was added with HTML5 (and balance theme doesn't appear to be html5).
But if it works on your home page, but not on your single pages, then maybe it isn't in the singles template???
December 6, 2014 at 5:03 pm #133856nathaniell
ParticipantI see that balance is not html5. The code that I showed above didn't change the home page featured post, I just edited some code in the grid loop section from "0" to "large".
December 6, 2014 at 11:03 pm #133864anotherusername
ParticipantOk, for a test, just try this:
Substitute this:
genesis_before_post_content
in place of this:
genesis_entry_header
In this line:
add_action ( 'genesis_entry_header', 'sk_show_featured_image_single' );
so instead it will read:
add_action ( 'genesis_before_post_content', 'sk_show_featured_image_single' );
And see if that at least SHOWS the image (even if it isn't in the exact right place).
Then let us know and we can try and take it from there.
December 6, 2014 at 11:23 pm #133866Brad Dalton
ParticipantDecember 7, 2014 at 6:26 pm #133935nathaniell
ParticipantThanks Brad, that did it. I had seen that post before but didn't realize my theme was xhtml and was using the html5 before. Oops! (Thanks to everyone else that posted an answer as well)
One follow up question for anyone:
How do I get the featured image to fill/crop to a uniform space size? I'd like to be able to add a featured image and just have it be uniformly sized across posts so I don't have to pre-measure each time.
December 7, 2014 at 10:10 pm #133947Brad Dalton
ParticipantThe size is set in the Genesis > Theme Settings > Content Archives settings.
This is the part of the code which does that
'size' => genesis_get_option( 'image_size' ),
Is that what you mean by uniformly sized across posts?
December 7, 2014 at 10:48 pm #133953nathaniell
ParticipantSorry, I should have included links.
You can see in the links below that each feature image has retained it's original size and shape. I'd like to have ALL the images fill about a 620x230 space regardless of what their upload size is.
http://brew7.com/stout-tasting-1-samuel-smiths-rogue-belhaven-shipyard/
http://brew7.com/libbey-craft-beer-glass-set-review/
http://brew7.com/is-the-rogue-left-hand-stout-glass-worth-your-money/December 7, 2014 at 11:21 pm #133954Brad Dalton
ParticipantDecember 8, 2014 at 8:23 pm #134038nathaniell
ParticipantThat does add the ability to change an image size that's uploaded to the post, but it doesn't change the size of the featured image. In his example, the "featured image" is just a selection like 'full size' or 'thumbnail'.
For example, if I choose "set featured image" and choose an image, it doesn't allow me to choose thumbnail, medium, full size, or any custom image sizes. It just takes the image as-is.
A good example of what I'm trying to do is here: http://www.ivetriedthat.com/
December 8, 2014 at 8:46 pm #134040nathaniell
ParticipantJust continuing to read up on this, and I think the term I'm looking for is "hard crop". I want to have featured images resized and hard cropped to 620x230
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.