Community Forums › Forums › Archived Forums › Design Tips and Tricks › Change size of Featured Image on Archives page only
Tagged: archives, category archives, featured image, genesis
- This topic has 6 replies, 2 voices, and was last updated 8 years, 7 months ago by senordeer.
-
AuthorPosts
-
March 7, 2016 at 4:57 pm #180835senordeerMember
Hello. I was wondering if there is a way to change the size of the Featured Image only on Archives pages. On homepage of blog:
I have the Featured Image set to be full size (in Genesis theme settings - Content Archives). However, I would like to show a smaller thumbnail, aligned left, on any archive pages. Of course if I make this change in the theme settings, it will also affect the post on the homepage. I know how to show more posts in a category than on the homepage, but it would be great to be able to change size of Featured Image as well as alignment on category archives pages:
http://casstravels.com/category/destinations/europe/england-europe/
Thanks!
http://casstravels.comMarch 7, 2016 at 5:09 pm #180841ᴅᴀᴠɪᴅMemberNot without writing code.
One way would be to have the Genesis settings to how you want it to appear on the archive pages, not the home page, then for the home page, create a seperate page template which switches out the default images and replaces them with the small thumbnail ones that you need.
To do this you would create a file in your child theme folder named home.php (if it doesn't exist) and add this;
<?php /** * This file controls the posts page */ //* Remove default featured image from posts page and replace with thumbnail. remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 ); add_action( 'genesis_entry_content', 'child_theme_add_thumbnail_image', 8 ); function child_theme_add_thumbnail_image() { $image_args = array( 'size' => 'thumbnail', 'attr' => array( 'class' => 'alignleft post-image', ), ); genesis_image( $image_args ); } genesis();
I love helping creative entrepreneurs build epic things with WP & Genesis.
March 7, 2016 at 5:34 pm #180848senordeerMemberDavid wow thanks so much for the quick response. So if I set the Content Archives theme settings to how I want the category archives to appear (small image, align left) but I want the posts on the homepage to show a custom thumbnail size (I already added this custom image size to functions.php, name is 'latestpost'), and I do not want any alignment on homepage, what would I need to change in the code you sent?
March 7, 2016 at 5:45 pm #180849ᴅᴀᴠɪᴅMemberSo then it would be
<?php /** * This file controls the posts page */ //* Remove default featured image from posts page and replace with thumbnail. remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 ); add_action( 'genesis_entry_content', 'child_theme_add_thumbnail_image', 8 ); function child_theme_add_thumbnail_image() { $image_args = array( 'size' => 'latestpost', 'attr' => array( 'class' => 'alignnone post-image', ), ); genesis_image( $image_args ); } genesis();
The class of 'post-image' is also added incase you need to style the image in anyway to align it better or whatever.
I love helping creative entrepreneurs build epic things with WP & Genesis.
March 8, 2016 at 2:00 pm #180933senordeerMemberThank you so much and apologize for delay in response, I really respect the timeliness of yours. So no problem, I created the home.php file, uploaded it to my child theme, I see it now in theme editor so I feel pretty confident I have done all of that correctly, also regenerated thumbnails just in case., but am still not seeing the size of the thumbnail on homepage change. Do I need to call that new php file somewhere else in my child theme?
I actually moved this site to a new domain, so examples can be found here:
Content archives in theme settings set to thumbnail, align left. So this works fine on archives pages eg:
http://metro.littlebluedeerdesign.com/category/destinations/But on the homepage (single post, beneath slider):
http://metro.littlebluedeerdesign.com/The same settings (thumbnail size img, left aligned) even though I did add home.php file as so:
<?php /** * This file controls the posts page */ //* Remove default featured image from posts page and replace with thumbnail. remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 ); add_action( 'genesis_entry_content', 'child_theme_add_thumbnail_image', 8 ); function child_theme_add_thumbnail_image() { $image_args = array( 'size' => 'latestpost', 'attr' => array( 'class' => 'alignnone post-image', ), ); genesis_image( $image_args ); } genesis();
Not a rush just wanted to respond back thanks again for the input much appreciated.
March 8, 2016 at 4:02 pm #180943ᴅᴀᴠɪᴅMemberAh I've just noticed you aren't using an html5 child theme. I didn't realise this before. The way I have given you is the 'new' way, but this won't work unless you have added support for html5. I am actually not that familiar with how Genesis worked before html5 support was added.
I do know that the hook I used 'genesis_entry_content' didn't exist. Instead it was called 'genesis_post_content' so you could try replacing that. Which would look like this;
<?php /** * This file controls the posts page */ //* Remove default featured image from posts page and replace with thumbnail. remove_action( 'genesis_post_content', 'genesis_do_post_image' ) add_action( 'genesis_post_content', 'child_theme_add_thumbnail_image' ); function child_theme_add_thumbnail_image() { $image_args = array( 'size' => 'latestpost', 'attr' => array( 'class' => 'alignnone post-image', ), ); genesis_image( $image_args ); } genesis();
If that doesn't work then I don't know, sorry. you would need to hunt back in google for tutorials on this dating back before mid 2013.
I love helping creative entrepreneurs build epic things with WP & Genesis.
March 8, 2016 at 4:55 pm #180952senordeerMemberThat worked! Yep, old school here, I should have mentioned that. For some reason the Featured Image also appeared aligned left on the homepage as well as the new larger image, but I just hid that in css:
.home img.alignleft { display: none; }
Bc I am only having one post on the page so won't be using that. Great, your time and effort is much appreciated, marking as resolved. Thanks again.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.