Mocha Image Help

Community Forums Forums Design Tips and Tricks Mocha Image Help

This topic is: not resolved

This topic contains 4 replies, has 4 voices, and was last updated by  Kelli 2 years, 6 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #25713



    I just added Mocha child theme to my blog ( 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!



    I 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.



    Ah, 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 :)



    This 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>



    @sallyuk – I’d love to know how you did this, too. Please share when you can!

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.