Community Forums › Forums › Design Tips and Tricks › Mocha Image Help
Tagged: featured image, images, Mocha, thumbnails
This topic contains 3 replies, has 3 voices, and was last updated by thedarkmist 1 month, 3 weeks ago.
-
AuthorPosts
-
March 12, 2013 at 2:39 pm #25713
Hi
I just added Mocha child theme to my blog (www.whosthemummy.co.uk) having previously used Fabric.
What I’ve noticed is my posts don’t display the image – in fabric you upload an image to the post and tick ‘set as featured image’ and the image displays on both the home/category page, and inside the post at a pre-defined size.
In Mocha, the image is attached when you upload it. I can display thumbnails in category pages by selecting this option in theme settings, but on the home page and subsequent archive pages there is no image visible – can someone tell me how I can make the images I’ve previously uploaded visible? Ideally I’d like a large featured image on the top post, and thumbnail images on the other posts.
I am REALLY not technical so simple advice would be so appreciated, thanks – I tried to understand the fix for the wonky menu and it went completely over my head!
March 13, 2013 at 7:40 pm #26091I just spent 30 mins trying to work out a solution to this, read some tutorials, wrote some code, got something kind of working, wrote it all out here, then looked at your site, realising that I hadn’t actually done that yet, and saw, to my horror, that you’ve already solved this!
Can you please tell me how? There must be a better way than the one I came up with, ha.
March 14, 2013 at 3:26 am #26147Ah, in the end I asked our developer at work to do it for me! I will ask him what he did and come back to share
March 28, 2013 at 9:29 am #31761This should work:
// Add support for featured image in pages and single posts
add_action( ‘genesis_post_content’, ‘insert_featured_image’, 5, 0 );
function insert_featured_image() {
if (is_single() || is_page()) {
if (has_post_thumbnail( $post->ID ) ) {
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), ‘medium’ );
$full = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), ‘full’ );
$alt = get_post_meta( get_post_thumbnail_id( $post->ID ), ‘_wp_attachment_image_alt’, true);
?>
<a href=”<?php echo $full[0]; ?>” class=”lightbox”><img src=”<?php echo $image[0]; ?>” width=”<?php echo $image[1]; ?>” height=”<?php echo $image[2]; ?>” class=”alignleft post-image” alt=”<?php echo $alt; ?>” /></a>
<?php
}
}
} -
AuthorPosts
You must be logged in to reply to this topic.