1

so this is sort of a continuation of another question that I had to ask recently. I wanted to start another conversation, since technically my last question was answered. The last question is here: Display Post Thumbnail Without Being Featured Image if you would like to get caught up on where I was, and where I'm at now.

I used to call the post's thumbnail with this:

if ( has_post_thumbnail() ) {
              the_post_thumbnail();

With no issues. Then I started to think that I would need it so that my client didn't always have to set a featured image for every post. Well, with no featured image, there was so post thumbnail being shown in the post's excerpt. So, because of the answer that I was given in the last question(link posted above), I am now using the Get The Image plugin along with this:

                                                     if (
 has_post_thumbnail() ) {
              the_post_thumbnail();
               }
               else
               {
                get_the_image( array('size' => 'thumbnail', 'image_class' =>
'wp-post-image'));   
               }  

Now, if there is no Featured Image chosen for a post, it picks the first image of the post's gallery, since there will always be a gallery for each post.

The problem now is that on the actual post, I have had it set so that the Featured Image is shown in full size right in the middle of the page. Thanks to this in my functions.php file:

// This theme displays full size featured image on the Post's page
function InsertFeaturedImage($content) {



global $post;

$original_content = $content;

if ( current_theme_supports( 'post-thumbnails' ) ) {

    if ((is_page()) || (is_single())) {
        $content = the_post_thumbnail('page-single');
        $content .= $original_content;

    }

 }
 return $content;
}

add_filter( 'the_content', 'InsertFeaturedImage' ); 

Before I added in the

               else
               {
                get_the_image( array('size' => 'thumbnail', 'image_class' =>
 'wp-post-image'));   
               }

It has worked fine. Now, it's just displaying the small thumbnail there right in the top middle of post's page. It should be displaying a full size image. So all this has brought me to the main two problems I'm now facing. 1) Can I edit that code in the functions.php file to still display the featured image in full size. And 2) What if there is no Featured Image chosen for a post, can I also make the functions.php code display the first image of the post's gallery, in full size?

I really hope this isn't too confusing. Please see http://dependablecarcompany.com and see the post excerpt titled, "1991 GMC Sierra". This post has no Featured Image, but a thumb is still being output, thanks to the Get The Image plugin. But when you actually click through to the actual post, you'll see that the top, center image is showing the thumb. It should be the full size image.

Thank you so much for anyone who can get through all this, and share some tips for me!

3
  • Deleted my answer as it doesn't work for you.
    – its_me
    Jul 27, 2012 at 2:06
  • Oh, it looks like that deleted my last post explaining how I got it to work though. Thanks for all your help with getting me up to that point though. Jul 27, 2012 at 2:37
  • Ah, just saw that you edited your comment with the links. Undeleted my answer, and edited it to reflect your suggested changes.
    – its_me
    Jul 27, 2012 at 2:45

1 Answer 1

1

Modify your function as such:

// This theme displays custom size (page-single) featured image on the Post's page
function InsertFeaturedImage($content) {

    global $post;

    $original_content = $content;

    if ( current_theme_supports( 'post-thumbnails' ) ) {

         if ((is_page()) || (is_single())) {

            $content = get_the_image( array( 'size' => 'full' ) );
            $content .= $original_content;

         }

    }

    return $content;

}

add_filter( 'the_content', 'InsertFeaturedImage' );

In the code, 'size' => 'full' defines the image size to be shown. You can choose between thumbnail, medium, large, full, or any custom image size that your theme uses (none in your theme). The default is thumbnail.

UPDATE: Answer last edited based on comment.

13
  • Thank you for your quick reply! I apologize, but I actually do have the code as you suggested. I just entered it wrong when I was asking my question. I went ahead and edited my question to show the write code. Jul 9, 2012 at 3:52
  • @AnthonyMyers Okay, see my edit. The size you are defining is thumbnail — If you want it to show a full-sized image, try full instead of thumbnail. EDIT I'll re-read your question to see exactly what's wrong.
    – its_me
    Jul 9, 2012 at 3:53
  • Now, the issue is though, that I want it to show the thumbnail size on the post's excerpt. You know, the small thumb that represents each post. If I choose the large size in that code, it will also show the full size image on the home page. I only want the full size shown on the post's actual page. Does that make sense? Jul 9, 2012 at 3:55
  • @AnthonyMyers If looks like your theme uses a custom image size page-single. See the edited code in my answer.
    – its_me
    Jul 9, 2012 at 4:00
  • Oh, fantastic. Ok, so would I just include the "page-single" in the code that you edited? I did try this, and it still shows just the thumbnail on the post's page. Plus, won't I have to edit or add to the code I'm using in the functions.php file? Because if no Featured Image is chosen for a post, I will need it to display the first image of the post's gallery, in full size. Jul 9, 2012 at 4:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.