202 Responses

  1. Andy Towler
    Andy Towler November 16, 2009 at 4:05 am | | Reply

    Thanks for this – I have a new WP magazine-style project coming up for which this will be ideal. Now I just have to hope that WP 2.9 is released in time for when I have to start the project!

  2. Ben
    Ben November 16, 2009 at 6:01 am | | Reply

    Hey Justin – that’s a pretty good round up. Thanks for linking to me too :)

    I agree entirely that this is a cool feature, and I will be making use of the ‘get_the_post_image’ function in my future themes, however for the actual resizing and cropping I think I will stick with TimThumb… for the time being at least :)

  3. Ryan
    Ryan November 16, 2009 at 6:11 am | | Reply

    Any idea why we now need to add the add_theme_support( ) function into our themes? I was using a trunk install and was surprised when it suddenly stopped working on upgrading after they required that function to be added. I can’t see what purpose it serves though.

    EDIT: I think I now know the answer. It’s so that the post thumbnail option doesn’t appear in the admin panel unless the theme supports it. That does make some sense, I just didn’t click until now.

    BTW, in the code block under “Checking if the post has an image” the code says it’s a link, but I think you intended to be an IMG tag.

  4. Ryan
    Ryan November 16, 2009 at 9:06 am | | Reply

    “I imagine the idea was to cut back on the number of support queries such as, “My post thumbnail isn’t showing!!!” ”

    Yeah. I could imagine the WordPress.com support forum getting inundated if they introduced that without adding support into EVERY theme on their site.

    I have sites of my own that don’t use thumbnails too and I imagine my post writers would also get confused by a strange thumbnail box that didn’t do anything whatsoever.

  5. Dan Philibin
    Dan Philibin November 16, 2009 at 9:22 am | | Reply

    I have probably used your Get The Image plugin on just about every theme I’ve done in the past month or two, so obviously the need is there for built-in post image support for WordPress.

    There’s still a problem with the media uploader, though, which could keep this system partially crippled. Sometimes I upload an image and insert it into the post but it’s NOT saved in the post’s gallery. WordPress’s post image feature probably won’t have the “image scan” feature that your plugin thankfully does, so hopefully they fix this with 2.9.

    Nice writeup!

  6. Cory howell
    Cory howell November 16, 2009 at 12:46 pm | | Reply

    This looks like a great feature that will save lots of time manually assigning thumbnails & working w/ 3rd party plugins.

    Kudos to WP for including this in 2.9 – very much looking forward to using it.

  7. Grant Palin
    Grant Palin November 16, 2009 at 1:20 pm | | Reply

    This is a long-needed addition to the WP core. I’ve used the custom field technique for some time, and it worked, but I thought it really should be part of WP out of the box. Looks like it will be soon enough! Thanks for the overview. Will keep the information in mind when I look at updating my site’s theme.

  8. The Frosty
    The Frosty November 16, 2009 at 2:26 pm | | Reply

    That’s pretty cool, I started to play with this feature in a theme I was working on, but I updated 2.9-rare a a few days back and that features magically disappeared…

    Got to play with it just enough though, may check the update, could be back by now..

  9. Steve Taylor
    Steve Taylor November 16, 2009 at 3:20 pm | | Reply

    Thanks for the summary. But… bah. I’m just finishing a site that could have done with this. What I’m doing is getting people to upload an image through the upload / insert popup, making the image title something like “featured”, then just saving changes (not inserting into post). So the image is attached to the post, with a specific title – I just use the normal WP attachment functions to grab the thumbnail of it.

    I’ll probably try and streamline things with this feature in the future, but out of curiousity, do you know if this new feature is separate from the “attachment” system? Is this image stored in the Media Library?

  10. Jean-Paul Horn
    Jean-Paul Horn November 16, 2009 at 3:53 pm | | Reply

    Will the new post images adhere to the image sizes we’ve defined in Settings > Media. From your (outstanding) article I gather that’s a Yes, which is unfortunate since our feature panel uses a non default image size (and for which I use the unrivaled Get The Image plugin with custom fields). I’ll probably leave it like we have now, although I might take advantage of this new feature to recode the theme slightly and have the feature box use the medium image. Adding a feature image is a lot of manual work right now and thus an unnecessary burden to our authors. The new Post Image feature makes this a whole lot simpler for them and I’ll just to need to add some extra code.
    Will definitely wait for the new Get The Image, since I’ll still be needing that :)

    Thanks Justin for both this explanation and your plugin(s)!

  11. Jay
    Jay November 16, 2009 at 4:22 pm | | Reply

    Nice that WordPress finally made that feature! Regarding that with the old thumbnails will be lost. Isn’t it possible to do something like this?

    < ?php
      if ( has_post_image() )
         the_post_image( 'thumbnail' );
      else
        echo '';
    ?>

    ($thumbnail is the custom field value)

  12. Jason Pelker
    Jason Pelker November 16, 2009 at 6:52 pm | | Reply

    I’ve been wondering when you might have some words about this new feature. I’m also curious if you have any development credits for getting this feature into WordPress 2.9.

  13. Tinh
    Tinh November 16, 2009 at 10:52 pm | | Reply

    Is this feature built in the WP 2.9 version or we need to manually tweak the theme? Thanks, it is cool feature indeed and I love it too

  14. Weekend Roundup #61 November 16, 2009 at 11:44 pm |
  15. Mike Smith
    Mike Smith November 17, 2009 at 12:10 am | | Reply

    This is awesome. Thanks for posting up the codes for it too – will definitely help when I launch a couple themes in the next two months.

    If I added the codes ahead of time to the functions.php file and added an if/else for the posts to either use this code or the default custom field code, would that break the theme if people use it with 2.8.6? I’m just thinking if I release the themes ahead of time before 2.9 comes out, I’d like to have this already built in.

    Thanks

  16. Ade
    Ade November 17, 2009 at 6:48 pm | | Reply

    Excellent write up as ever Justin.

    I’m just wondering… how (if even possible), would you make it so the thumbnail is linked to article for navigation purposes

    My theme came with “get the image” plugin built it

    I’ve implemented the code above on a mirror test site of my site, replacing the following code…and although the images are appearing fine, they are obviously not clickable. And unfortunately my php knowledge is not good enough to work out the code i need. Can you point me in the right direction.

  17. Ade
    Ade November 17, 2009 at 6:51 pm | | Reply

    sorry – my code got dropped… i don’t know the command to show code, it’s clearly not backtick as i’ve become used to.

  18. Faizal
    Faizal November 17, 2009 at 11:22 pm | | Reply

    I’ve currently tested the Wordpress 2.9 Beta-1 but can’t found that Post Thumbnail Meta Box in the post editing screen. Anyone know why ???

  19. Agung
    Agung November 18, 2009 at 2:00 am | | Reply

    great info.. but any know how to auto resize image..? not large to small. but from small to large post inside. thanks

  20. Morten
    Morten November 18, 2009 at 8:45 am | | Reply

    I guess it is going to work pretty similar to the feature like i have on my template, if so it is absolutely great.

    I especially like the feature with usage of default picture i am missing that part on my template.

  21. Darran
    Darran November 18, 2009 at 8:34 pm | | Reply

    Nice tutorial, I could follow it quite easily and will probably not get down to testing this feature until 2.9 is officially out due to my sheer laziness. This means one less plugin to themes who want to have a custom post thumbnail.

  22. Jessi
    Jessi November 19, 2009 at 7:46 am | | Reply

    My site also could’ve used this. Oh well. I’ve been using a plugin called Smart Image for a while now. It doesn’t use custom fields though. Come to think of it, it’s pretty much exactly like the new WP feature. It’s just not built-in obviously.

  23. john@Baby Pushchairs
    john@Baby Pushchairs November 19, 2009 at 3:39 pm | | Reply

    Before reading your post, I had so many queries regarding how to post the image feature in Wordpress. But, now, I don’t think that I have any doubts regarding that. Thanks for the information.

  24. Ridgely
    Ridgely November 19, 2009 at 3:56 pm | | Reply

    Ok, this is a painter-needs-to-build-her-own-damn-website dream come true. At least I think – could you use this feature to more effectively whip up a site like this?

  25. Morten
    Morten November 20, 2009 at 5:14 am | | Reply

    @Justin

    That is great news from all wordpress bloggers, i picked my template as my pages basically is about travelling, and pictures in that case is a must have.

    The number of visitors, which pictures can create totally surprised me, the tricky part is to get them on the page, not just having them look at the images they found in Google.

    Anyway great news, that the new Wordpress feature will work similar to the Get the Image functionality.

    Morten

  26. Weekly Links #80 | GrantPalin.com November 22, 2009 at 3:20 pm |
  27. KokPinLab
    KokPinLab November 23, 2009 at 4:06 am | | Reply

    Hi Justin,

    I always like your post and it is so simple and concise to learn some new feature on wordpress.

    Thank you.

  28. Jake
    Jake November 23, 2009 at 10:02 am | | Reply

    Great information, thanks for sharing. The code is really helpful as I am planning an upgrade once 2.9 is released. I’m a first time visitor and wanted to say this looks to be a very useful blog. Your work is much appreciated!

  29. Kelli - PLC Programming Guru
    Kelli - PLC Programming Guru November 24, 2009 at 1:26 pm | | Reply

    Justin,

    Thanks for the step-by-step. Frankly, I’m not the most technically inclined person but based on your explanation I think that I will be ready to use Post Thumbnail once I upgrade to WP 2.9. Hopefully, both will be as “easy” as I would hope.

  30. Ashley Lekov
    Ashley Lekov November 24, 2009 at 2:12 pm | | Reply

    Thank you for the informative post, as always. Looking forward to the upgrade.

  31. moshe ovadia
    moshe ovadia November 28, 2009 at 3:38 am | | Reply

    i try the beta of wp 2.9 but icant find any Page thumbnail box !!!
    “you’ll see a new meta box labeled “Post thumbnail” (or “Page thumbnail” for pages).”
    where is the post thumbnail.

  32. moshe ovadia
    moshe ovadia November 28, 2009 at 4:28 am | | Reply

    Ohhhhh, i understand now “add_theme_support( ‘post-thumbnails’ );” at the first i thought the function used only for theme support!!!! not for the admin post or page editing

  33. Andri
    Andri November 29, 2009 at 7:21 am | | Reply

    And I am so satisfied with the auto thumbnail script in your hybrid theme… with an easy single clicks any articles will have customized image thumbs :)

  34. brainsolid
    brainsolid November 29, 2009 at 3:18 pm | | Reply

    Justin, you talking about Get the Image plugin, that help do not lose old thumbs. Are there some way to resize these old thumbs?
    For example, i use 100×100 px thumbs and now want to enlarge them to double-size.

  35. Doug Bedient
    Doug Bedient December 1, 2009 at 10:14 am | | Reply

    Added the code bit to my themes function.php file at the last line 434 and no activation. Emptied cache. Different browsers. Still not there. Curious… 2.9-beta-1. This is the most complete, easy to follow article I’ve found though. Good work.

  36. Suzanne
    Suzanne December 1, 2009 at 6:25 pm | | Reply

    Justin thanks for the great article – I’v got this implemented in an upcoming revision of a fairly large magazine site I manage. I have a question tho – you don’t happen to have an easy way to get just the URL of the post image (by size) do you? These functions get the entire IMG tag, but I’d like just the URL to the image itself.

  37. darila
    darila December 3, 2009 at 5:28 am | | Reply

    Well, it breaks some stuff in older installations, but its a very nice new feature in wordpress 2.9

    greeting, darila

  38. Aldo
    Aldo December 5, 2009 at 5:43 pm | | Reply

    Hi Justin,

    there is a typo in the code block under the paragraph “Changing the HTML output of the post image”. At the end of the second line, there is a ; instead of a {

    Thanks for your helpful posts.

  39. WordPress 2.9, c’est pour bientôt ! December 7, 2009 at 1:27 pm |
  40. bob
    bob December 8, 2009 at 2:07 pm | | Reply

    I tried it out, and it looks like the only thing that the Post Thumbnail write panel adds is the ability to just embed an image in your post. I thought it would have been a separate feature, where in previews only the post thumbnail would be displayed or some different type of functionality. But it only gives you the ability to insert an img tag in your posts. Does it do more? What’s the reason behind the hype?

  41. Matt M.
    Matt M. December 8, 2009 at 10:03 pm | | Reply

    It’s great that they are implementing this feature into wordpress finally. As time has progressed and thousands of blog themes have been developed, a ton of them are including thumbnails next to the posts and excerpts. It is not exactly easy to hand-code this all the time, especially for inexperienced developers. I can also see this feature being great for portfolios and case study pages!

  42. jamee
    jamee December 9, 2009 at 7:11 am | | Reply

    I really love to use wordpress and as stated here there are so many blog themes avilable and these things should have in mind while using wordpress. This post makes those very well aware who just have to use this but are not aware of it well.

  43. bob
    bob December 9, 2009 at 2:18 pm | | Reply

    But Matt M., it’s as easy as simply typing in your post content…

  44. Fairweb
    Fairweb December 9, 2009 at 2:49 pm | | Reply

    Thanks Justin,
    I had written something similar on my blog (in french) http://weblog.fairweb.fr/archives/2009/12/05/wordpress-2-9-la-vignette-dun-article-en-natif/ and just linked back to your post as it is much more detailled.
    I’ve also written a plugin http://wordpress.org/extend/plugins/fw-post-image/ where I used your idea (and a couple of lines of code) of scanning the post content. Feel free to extend it as you wish or, if your plugin does something different, take some of my code if you find it helpful. Do not hesitate to contact me by email.

    Myriam

  45. Devin
    Devin December 10, 2009 at 6:22 pm | | Reply

    Thanks for the write up Justin. I was curious if it worked on pages as well as posts. Just added the code and it does.

  46. Kretzschmar
    Kretzschmar December 14, 2009 at 6:50 pm | | Reply

    Just a small note. The WordPress Team has renamed those new functions. instead of _image all functions end with _thumbnail. So has_post_image becomes has_post_thumbnail.

  47. Fairweb
    Fairweb December 17, 2009 at 12:16 am | | Reply

    I searched for get_the_image plugin in the WP extends but did not find any new update. When do you intend to release it ?

  48. William Lindley
    William Lindley December 18, 2009 at 4:42 pm | | Reply

    One example of a plugin that already supports 2.9 is the AutoNav plugin ( http://wordpress.org/extend/plugins/autonav/ ). It uses the “post thumbnail” when it creates a table of child-pages… so if you have a page, “Cruises” and each of its child pages (Tahiti, Hawaii, etc.) has a post-thumbnail, you would get a set of images like a menu of them.

  49. Jauhari
    Jauhari December 21, 2009 at 12:09 am | | Reply

    I still enjoy your Get The Image plugin ;) But this features also useful

  50. Wordpress 2.9 er ude » kraenbech.dk December 21, 2009 at 12:02 pm |
  51. Urlaub Kroatien
    Urlaub Kroatien December 24, 2009 at 8:46 am | | Reply

    Marry Christmas and happy New Year 2010 from croatia.

  52. Danne
    Danne December 28, 2009 at 7:41 pm | | Reply

    This was really a great tutorial, considering every aspect I would say. I’ve copied it and will use it. It will help me right away. Thanks

  53. JHouse
    JHouse December 30, 2009 at 3:49 pm | | Reply

    Yesssssssssssssssssssssssssss!!! I was using Post Thumbs Revisted for the last year or so, but it wasn’t working properly after I upgraded to the latest WP. Soooo, I tried numerous other plugins, but none of them met my client’s needs. With the plugin you suggested, coupled with WP 2.9 and your custom code, it all works like a champ now. So stoked!!! Thank you so much for your WP wisdom.

    Happy New Year!!!

  54. webmatrix
    webmatrix January 2, 2010 at 1:32 am | | Reply

    Thanks for the review. Now I’m just finishing a site that could have done with this. What I’m doing is getting people to upload an image through the upload / insert popup, making the image title something like “featured”, then just saving changes .
    Thank a lot for sharing youre good thought……….

  55. Jamie O
    Jamie O January 4, 2010 at 3:37 pm | | Reply

    LOVE the potential of this – especially with being able to edit separate crops for the separate photo sizes. Square thumbnails for product galleries with more appropriate non-square for detailed photos.

    Having a strange quirk that when I put the add_theme_support( ‘post-thumbnails’ ); in my functions.php file and refresh in the admin, any time I try to select a photo from the media library it shows no results. Remove the line and the list of photos does show. Any thoughts?

  56. Babel
    Babel January 6, 2010 at 5:09 pm | | Reply

    “What happens to my old images/thumbnails?”
    why dont use the old AND new method? if there is a special-field declared then use it. if not use the new method no prob ;)

  57. Babel
    Babel January 7, 2010 at 2:10 pm | | Reply

    “How to return the image instead of displaying it” thx that helped me very much that was the problem i’m searching for! :)

  58. wordpress seo
    wordpress seo January 9, 2010 at 8:56 am | | Reply

    Thanks for the write up Justin. I was curious if it worked on pages as well as posts. Just added the code and it does.

  59. Bjarne // Mums Studio
    Bjarne // Mums Studio January 10, 2010 at 8:41 pm | | Reply

    Justin, a very good read! Wasn’t aware of the possibility to edit the HTML output. That’s really handy…!

    Thanks.

  60. Chas
    Chas January 16, 2010 at 11:35 am | | Reply

    Does anybody know if we can have next and previous thumbnails for navigation on posts and what the code would be?

    (This article was very helpful and was an asset for me setting up my website for post thumbnails.)

    1. Chas
      Chas January 27, 2010 at 9:29 pm | | Reply

      I am replying to my question. A plugin has been developed that works as a widget and shows the next/ previous thumbnails. It also has several other nice options. The name of the plugin is called “Post Navigation Widget”. It can be downloaded from from the Wordpress Pligin Directory.

  61. WordPress 2.9 “Carmen” is out! January 17, 2010 at 11:02 pm |
  62. links for 2010-01-18 | Digital Rehab January 18, 2010 at 7:37 pm |
  63. nagradne igre
    nagradne igre January 19, 2010 at 4:52 am | | Reply

    Its a lot of nice features in 2.9 version od wordpress
    I was searching for how to return the image instead of displaying it and found it here, thanks…

    greetings, nagradne igre

  64. wordpress » XMM.IR January 20, 2010 at 5:26 am |
  65. Ruth @ WordPress Toronto
    Ruth @ WordPress Toronto January 21, 2010 at 9:56 am | | Reply

    Great post. I’ve been using the Get the Image plugin on most of my sites making for a smooth transition to 2.9. Check out my latest post for an updated detailed walk through of the new Image Editing features. Uploading and Editing Images in WP 2.9

    Thanks

    ~ Ruth

  66. Using Post Thumbnails in WP January 22, 2010 at 10:35 am |
  67. Ceapa
    Ceapa January 24, 2010 at 2:43 pm | | Reply

    This was really a great tutorial, thanks!

  68. Istrien
    Istrien January 24, 2010 at 3:33 pm | | Reply

    Thanks for helpful post.

  69. Andy H
    Andy H January 25, 2010 at 10:49 am | | Reply

    Thanks for the lovely article. One thing I cant figure out is how to get the thumbnail to act as a link to the ful size image? Not to the post.

    Thanks again :)

  70. Zac
    Zac January 29, 2010 at 7:24 am | | Reply

    Nice article, do you know how you can return the filename rather than the ID of an image being used?

    I want to return the filename of an image being used on a main page, then modify it so I can use it to call another image for the subpages depending on what template is being used for the sub pages (i.e. main page thumb = “image-wide”; sub page thumb = “image”-narrow).

    Unfortunately I can’t just resize and re-use the image as it won’t fit the templates.

    Thanks,

    1. Zac
      Zac January 29, 2010 at 7:37 am | | Reply

      Sorry, to clarify… I thought that your instructions under “How to return the image instead of displaying it” ($image = get_the_post_thumbnail( $post->ID, ‘thumbnail’ );) would do this but it doesn’t seem to, it just displays a thumbnail version on my page.

  71. Myshock
    Myshock January 29, 2010 at 5:31 pm | | Reply

    I justin. Thanx for this article.
    I would like to extract the post thumbnail url to use it with css.
    How can i do that ?
    is there a function like “the_post_thumbnail_url”
    Thanx for help.

  72. Myshock
    Myshock January 29, 2010 at 6:52 pm | | Reply

    Sorry to annoy you seemed to be something like that :

    Wrote that little function that works fine.

    [code]function get_post_thumbnail_url( $post_id = NULL ) {
    global $id;
    $post_id = ( NULL === $post_id ) ? $id : $post_id;
    $image_id = get_post_meta( $post_id, '_thumbnail_id', true );
    $image_url = wp_get_attachment_image_src($image_id);
    return $url[0];
    }[code]

    1. Myshock
      Myshock January 30, 2010 at 3:18 pm | | Reply

      I’m sorry last line is :

      “return $image_url[0];”

  73. Mufet
    Mufet February 1, 2010 at 4:01 am | | Reply

    until now I still use wordpress 2.8
    not dare to upgrade
    btw, thanks for the tutorial

  74. post_2 – de joaca February 2, 2010 at 9:38 am |
  75. Eric S
    Eric S February 3, 2010 at 12:50 pm | | Reply

    I am trying to plug-in my own code to make the WP post thumbnails link themselves to the article.

    I already added in the archives pages and templates page the ability to do this.
    But on my single post page, I want that image to link to a full size.

    Right now I have only <a href="#" rel="nofollow"> and I am not sure what the tags are to pull those full size images in, any thoughts?
    Thanks

  76. bbunker » T2010020501 February 5, 2010 at 4:42 am |
  77. Wendy
    Wendy February 11, 2010 at 7:04 pm | | Reply

    I like the code under ‘Changing the HTML output of the post image’. It automatically adds the title (alt post title) to an image. But I want to get rid of this…. :(

    It’s impossible :(

  78. Peter
    Peter February 15, 2010 at 7:45 pm | | Reply

    Justin,

    Do you know if there is a way to add a rollover effect to post thumbnails?

  79. Jeremy
    Jeremy February 16, 2010 at 11:26 pm | | Reply

    Justin,

    Is there a way to use the_post_thumbnail(); outside of the loop?

  80. Margarida Fernandes
    Margarida Fernandes February 17, 2010 at 3:39 am | | Reply

    I’m a newbie at this wordpress programming and I still can´t figure how to display my pages and subpages using this. All I see here is code for Posts not pages.
    I still don’t understand what it means to be ‘in the loop’. I am not a programmer. I am still begging to learn these things.
    Can anyone help me with the code for displaying subpages inside a page?

  81. WordPress 2.9 is out! | WordPress | WereWP February 18, 2010 at 12:28 pm |
  82. iPhoned.nl
    iPhoned.nl February 24, 2010 at 2:29 pm | | Reply

    Hi Justin, great tutorial. We will use the thumbnail feature within our new theme. Thx!

  83. Bane
    Bane February 24, 2010 at 9:35 pm | | Reply

    Justin, I thought this might be useful to your readers.

    Next & Previous Post Titles With Thumbnails: http://wordpress.org/support/topic/368725

  84. Dave
    Dave March 3, 2010 at 11:55 am | | Reply

    Using the built-in wordpress thumbnail feature seems to add *many* extra queries when I used it in my loop. I think I’ll go back to my custom field solution.

    I use the debug queries plug-in from time to time, and I found out that my queries nearly doubled to 40-something after using the built-in thumbnail feature.

    Anyone uncover something similar to this?

  85. Insel Hvar
    Insel Hvar March 3, 2010 at 1:29 pm | | Reply

    I especially like the feature with usage of default picture i am missing that part on my template.

  86. Pragati Sureka
    Pragati Sureka March 5, 2010 at 7:31 am | | Reply

    Thanks for amazing guide to wordpress thumbnails… specially “How to return the image instead of displaying it”.

  87. gr33n
    gr33n March 5, 2010 at 11:01 am | | Reply

    “Changing the HTML output of the post image
    In this example, I’ll show you how to wrap the image with a link to the post”

    using it and it is great … but i wonder if it is possible to limit this feature only to archive pages … or rather – to exclude single posts from it, since when image appears in single post there’s no need to link to same single post …

  88. Križarjenje
    Križarjenje March 11, 2010 at 10:51 am | | Reply

    Great post, and a lot of comments, congrats… :)

    Found how to return the image…

    greetings, Križarjenje

  89. TOEIC
    TOEIC March 14, 2010 at 5:58 am | | Reply

    Thank you for this great explanation. I has always many problems with images.

  90. Javi A.
    Javi A. March 14, 2010 at 7:11 am | | Reply

    Hi everybody !
    Thanks to the author for this hopeful article !!
    I was trying to show thumbnails in my post excerpts.
    I’m trying to get the easiest and more authomatic way for showing them.
    This is my plan: to show a thumbnail with the same name as the post id + jpg (or gif or so on).
    Does anybody know what should I do for getting it?

    Thanks a lot in advance !

  91. Sabuj kundu aka manchumahara
    Sabuj kundu aka manchumahara March 21, 2010 at 12:38 pm | | Reply

    I think after adding this line in my theme
    add_theme_support( ‘post-thumbnails’ ); I am getting attachment url in place of post url after uploading image and in popup image edit window. There is option for none, file url and post url but I am getting attachment url as post url …. my permalink is like /%year%/%monthnum%/%post_id%.html

    Any one got same problem ?

  92. Solo
    Solo March 21, 2010 at 1:09 pm | | Reply

    hi all ..
    I have a problem. I write a post. Insert thumbnail and click on publish but that does not save the thumbnail. I have to write the post, publish it and THEN insert the thumbnail. Am I doing something wrong or is this the default behavior?

  93. Sarang Walet
    Sarang Walet March 25, 2010 at 11:24 am | | Reply

    Nice tutorial, The thumbnail looks good. thanks for sharing

  94. Bobby
    Bobby April 3, 2010 at 2:32 pm | | Reply

    This has been very helpful.
    Thanks

  95. Will Ashworth
    Will Ashworth April 19, 2010 at 7:14 pm | | Reply

    Is there any way to access the path of one of these images instead of having it output an image tag? I need specifically the path itself…nothing more.

    We’re intending to pass it into flash via a flashvariable and need the path instead of the actual image tag. I could strip it out via strstr() but that’s messy and could break later with a WordPress core upgrade.

    Right now we’re using:

    the_post_thumbnail(’some-special-size-here’);

    I have tried this as well but it still outputs the image tag with it…

    $image = get_the_post_thumbnail( $post->ID, ‘some-special-size-here’ );

  96. Will Ashworth
    Will Ashworth April 19, 2010 at 7:22 pm | | Reply

    I found that parsing the URL out works, but it’d be great if Wordpress could add built-in functionality to grab just the URL instead of forcing us to use the IMG tag.

    http://polymathworkshop.com/shoptalk/2010/03/19/get-the_post_thumbnail-direct-path-for-wordpress/

  97. Trisha
    Trisha April 21, 2010 at 6:33 pm | | Reply

    Any idea if this works for Page thumbnails? I’m trying to list child pages using this code. (the 2nd one, in ‘post format’). Switched out all instances of ‘content’ with ‘excerpt’ and used Andrew Oz’s Excerpt Editor which is seriously cool.

    When I try to plug in the code for the thumbnail, it doesnt show.

    Any idea what I might be doing wrong?

  98. Dan
    Dan April 24, 2010 at 9:51 am | | Reply

    Wow…you saved light years of me trying to figure out these thing by myself.
    This post is GOLD…thank you for sharing :D

  99. Bob
    Bob April 26, 2010 at 10:26 am | | Reply

    How do you add lightbox or thickbox (example rel=”lightbox” or class=”thickbox”) to the thumbnail?

  100. Rich
    Rich April 28, 2010 at 1:05 pm | | Reply

    Great stuff you had here. Those were really helpful tips for me although Wordpress 2.9 is an old version and there are new version for this. I am hoping it works with the latest version. The feature was very useful for beginners like me. Thank you.

  101. Yahya Ayob
    Yahya Ayob April 28, 2010 at 11:08 pm | | Reply

    Hey Justin, I’m a fan of this add on support for uploading images.

    It works great for me but I tried something which I had no idea why.

    I set my user role as Contributors and when I try to click Set Thumbnail, nothing happens!

    Could you figure this out? Should I change the user role to Author?

    Look forward to hear from you, Justin. =)

  102. Dan
    Dan May 4, 2010 at 12:43 pm | | Reply

    I added the code under “Changing the HTML output of the post image” and it works great except the image title is the title of the image NOT the title of the post. If I mouse over the very bottom right of the image it has the post title but the rest of the image is the title tied to the image itself.

    Anyone have any ideas on how to fix this? Any way to trim the $html string off after “title=’ ” and add in the Post Title so that the image will have the correct data?

    Here is how the page source reads currently:

    1. Reg Tait
      Reg Tait May 5, 2010 at 2:42 pm | | Reply

      Yeah, struggling with this bit too. You can always just change the title of the image as a workaround.

  103. David
    David May 6, 2010 at 3:17 pm | | Reply

    These are really one of my big questions few months ago when I was still new with wordpress and I don’t know some features and uses of it. Until, I got into your site and you really have so many important lecture/ideas for beginners like me and everyday visit to your site provides me new ideas in improving what I really want to do in my life. Thank you.

  104. Jason Pereira
    Jason Pereira May 18, 2010 at 10:29 pm | | Reply

    I must say you’ve created a very helpful source for beginners like me. Although I knew some part of it there are still facts and codes which I learned from you. Thanks a lot.

  105. SS
    SS May 30, 2010 at 8:01 pm | | Reply

    Hi there.. thanks for the info..

    i’m wondering?? how do i get the ‘thumbnail’ to show up in this query??

    post_title; ?>
    post_content; ?>

    iv tried a few things but nothing seams to working
    Kindly

  106. Magdy
    Magdy June 7, 2010 at 5:43 am | | Reply

    Hi Justin, nice explanation!

    I have just one question, is there a way to remove the post thumbnail from the image gallery of the post?

    The reason I’m asking this is because all my posts have an image gallery and I don’t want to have the post thumbnail inside this gallery.

    Hope you can help me!
    Thanks

    1. Magnus Cederholm
      Magnus Cederholm June 17, 2010 at 7:25 am | | Reply

      I’m also wondering about this..

      Without this function this new feature is rather worthless since you could just have used thumbnailversions of an image as a thumbnail.

  107. jeherve
    jeherve June 22, 2010 at 4:20 am | | Reply

    I have got a question regarding this the_post_thumbnail I got it working, it is a great new feature, but I now face an issue when I want to add a new size of thumbnail.
    It works perfectly and creates a new thumbnail for all new posts, but it does not create a new thumbnail size for the old posts. How can I solve that issue?

    Thanks for your help!

  108. Rasel
    Rasel June 26, 2010 at 3:16 am | | Reply

    I tried , but i cannot get any effect of this modification in my site.

  109. Yurckk
    Yurckk July 9, 2010 at 8:50 pm | | Reply

    Great posting on the image feature, I just noticed about it lol.

  110. Toni L
    Toni L July 21, 2010 at 8:42 am | | Reply

    How can I pull the image meta data for PHP?

    1) Let’s say I want to assign $width_of_the_image variable to check that image is under or over certain size.

    2) Then I can compare this size to my set values and give the image a proper class to handle the output nicely.

    Maybe a tutorial?

    1. Toni L
      Toni L July 21, 2010 at 10:19 am | | Reply

      Here is some nasty code that worked for me:

       image = get_the_post_thumbnail( $post->ID, 'single_post_thumbnail' );
      			  function getAttribute($attrib, $tag){
      				//get attribute from html tag
      			$re = '/' . preg_quote($attrib) . '=([\'"])?((?(1).+?|[^\s>]+))(?(1)\1)/is';
      			if (preg_match($re, $tag, $match)) {
      			return urldecode($match[2]);
      			}
      			return false;
      			}
      			$tag=$image;
      			$width = getAttribute('width', $tag);
      			$title = getAttribute('title', $tag);
      			$alt = getAttribute('alt', $tag);
      					if($width > 350) {
      					the_post_thumbnail('single_post_thumbnail');
      					}
      					else{
      						the_post_thumbnail('single_post_thumbnail', array('class' => 'alignleft'));
      						}
      					the_excerpt();
      					}  
      
      				else{ the_excerpt();} ?>
  111. baa
    baa July 22, 2010 at 7:54 pm | | Reply

    Hi Justin,

    thanks, this article helped me a lot.

    Like Bob – April 26, 2010, i would also like to put a lightbox on the image.

    How do you apply the extension (.jpg or .png or.gif) to the image?

  112. Raphael Essoo-Snowdon
    Raphael Essoo-Snowdon August 4, 2010 at 12:17 am | | Reply

    Is there a way to set a SET size for these post thumbnails?

  113. Tony Stark
    Tony Stark August 11, 2010 at 6:44 am | | Reply

    Is there any plugin that does this work? There’s no thumbnail how ever i tried.

  114. mark
    mark August 12, 2010 at 11:55 am | | Reply

    Is there a way to pull the featured image URL for use in the head? Here is what I would like to do – Im trying to add something like this to the head of my single.php pages –

    <link rel="image_src" href="ID, 'thumbnail'); ?>" />

    However, this doesnt work. All I need is to point it to the URL. Any ideas? Thanks.

  115. lv
    lv August 17, 2010 at 12:15 pm | | Reply

    Hey Hackadelic,

    I was thinking of some sort of anchor and “a” name situation. i have done this before with an accordion, but it was out side of wordpress.

    Regards
    fff
    Luke

  116. James Tryon
    James Tryon August 24, 2010 at 12:37 pm | | Reply

    Im looking for a way to have two featured images.

    One for the thumb nail and a 2nd one for a Call to action slider im making.

    I would like my client to be able to upload an image just like the featured image works, and have two area on the left side for images.

    I have been googleing for hours ;c )

    I understand custom post types and taxonomies, i have written several plugins. Just looking for a push in the right direction.

    Thanks and great post.

  117. Thorsten
    Thorsten August 28, 2010 at 5:40 am | | Reply

    Hi Justin,

    Thanks for the great explanation. I am not an expert and therefore allow me one question.
    I would add some text to the title prior to the name of the picture. Something like:

    Click here to get to the picture ‘ + post_title + ‘

    What would I have to add to the function.php to achieve this?

    Thanks & Bests
    Thorsten

  118. Trevor Maskery
    Trevor Maskery September 29, 2010 at 9:22 am | | Reply

    is there anyway of using this to just produce the url for the featured image?
    i need to use the the featured images twice one in a thumbnail with a seperate style and an alignment to the one on the post.

    is there a way of extracting the image location from the ID?
    was a little confused by the html editing section of this post :S

  119. Michelle
    Michelle October 27, 2010 at 5:31 pm | | Reply

    Hi Justin, hoping you can point me in the right direction for a problem I’m having.

    I’m using the plugin on a site that requires transparent thumbnails due to the design. I’ve tried Gif and PNG files, and the thumbnails lose the transparency and show up as black. I’ve searched for a solution online, but have not been able to find one.

    Hoping you might now the fix?

    Thanks

  120. Michelle
    Michelle October 27, 2010 at 5:37 pm | | Reply

    Hi Justin, found the solution to my problem, so posted again in case others have the same issue. I discovered the PNG files have to be saved as 24bit – the resolves the black background.

  121. Dallas Moore
    Dallas Moore November 12, 2010 at 4:43 pm | | Reply

    That was ALMOST everything I needed to know about the post image feature. :) Now I just need to know if I can change the alt tag for the image. I’ve seen people that say I can’t, but I don’t like that word. I’ve also seen the codex page for the_post_thumbnail and the default attribute Wordpress assigns to it. Can I somehow use this information to change it?

    Your response is GREATLY appreciated.

    Dallas

  122. Kwame Busia
    Kwame Busia November 17, 2010 at 4:00 am | | Reply

    Fantastic post, that was really really useful. Thanks alot – now I know my way around adding featured post thumbnails!

  123. Ivan Lee
    Ivan Lee November 29, 2010 at 11:24 am | | Reply

    great post, its was what i need for my WP website. thanks very much and now i know how to adding post thumbnails…..!

  124. Stepan
    Stepan December 11, 2010 at 12:15 pm | | Reply

    Thanks a lot for clear instructions. Now I will use thumbnails at archive pages :)

  125. Alain
    Alain December 16, 2010 at 9:59 pm | | Reply

    Hey, thanks for the info.

    -But, how do i get an image to resize, only to fit its smallest side in the box? (thus, fitting inside but cropping a little it’s larger side)…

    Sort of the reverse of hard crop.

    Thanks.

  126. Michael
    Michael December 22, 2010 at 10:29 pm | | Reply

    Hi Justin,

    In my search to find out how can I fix my problem, I found your site. I’m just starting to layout my site and I came across some issues. Under my archives menu, I made a few sub-menus linking to some of my test post. When you click on any of the sub-menu. It only displays some on my text and none of my photos. You have to click again on the heading of the post to display the entire post. Is their a way to display my entire post with images, as soon as I click on the sub-menu links. Here is a sample of a site who does just what I want to do http://www.munroephotography.com/blog/

    Thanking You In Advance!

    -Mike

  127. Christian Sisson
    Christian Sisson December 30, 2010 at 1:22 am | | Reply

    Perfect!!!!!!!!!!!!!!!!!!!

    Thank you a thousand time :)

    Happy new year!

  128. erdem tasarhane
    erdem tasarhane January 26, 2011 at 5:12 am | | Reply

    thanks for the detailed explanation…

  129. Jeff Meadows
    Jeff Meadows March 6, 2011 at 5:36 am | | Reply

    Wordpress allows you to set a custom link for an image. Does any one know how to display the featured image with that link? The idea is to click on a featured image and go to an external website as set in the image link box; not the post and not the file.

    1. Mike Targett
      Mike Targett May 15, 2011 at 6:58 pm | | Reply

      Ever get a response about this?

  130. Mads ny
    Mads ny March 17, 2011 at 5:33 pm | | Reply

    Hi guy’s
    i spend some time to figure out how to show featured images from PAGES within a loop, where it seems you have to use get_the_post_thumbnail instead, here’s what i found if anyone should be puzzeling with the same issue. :)

    60,
    	        'post_type'   => 'page',
    	        'post_status' => 'publish'
    	    )
    	);
    	if ( $latest_content->have_posts() )
    	{
    	    while ( $latest_content->have_posts() )
    	    {
    	        $post = $latest_content->next_post();
    
    	        // Do anything you know about the loop.
    			if(get_the_post_thumbnail($post->ID)){
    			?>
    
    				<a href=""> ID); ?> </a>
  131. Frank
    Frank March 20, 2011 at 12:44 pm | | Reply

    Hi Justin,
    Thanks for guide to wordpress thumbnails…
    Regards Frank

  132. Mathias Rangel Wulff
    Mathias Rangel Wulff April 18, 2011 at 6:56 am | | Reply

    If you must have an image on “home” (as autofokus) place this in your functions.php

    function echo_cover_image_url($post_ID, $size='large'){
    	$imgData = wp_get_attachment_image_src(get_post_thumbnail_id ( $post_ID ), $size);
    	$imgUrl = '';
    	if(is_array($imgData)){
    		echo $imgData[0]; //featured image
    	} else {
    		the_post_image_url($size);	//fall back on last uploaded image
    	}
    }

    and call echo_cover_image_url(get_the_ID(), 'large') from the loop.

  133. Harpreet Grover
    Harpreet Grover May 8, 2011 at 11:15 am | | Reply

    Reg: get_post_thumbnail_id()

    Hi Justin,

    I want to display an image only if set through featured image. Esle, diaply nothing.
    But it takes an image from the post to display there.

    Is there any other method.?

  134. Mark "Chief Alchemist" Simchock
    Mark "Chief Alchemist" Simchock June 8, 2011 at 1:57 pm | | Reply

    Thanks for getting me started with WordPress and images, Justin.

    I’ve since tossed together a primer on WordPress and images. It’s not as thorough as your article but I think some might find it helpful.

    http://www.chiefalchemist.com/primer-wordpress-and-working-with-images/

    Let me know what you think. Maybe I should present it a bit differently?

  135. Image sizes in WordPress June 24, 2011 at 1:05 pm |
  136. bren
    bren June 29, 2011 at 2:43 pm | | Reply

    Brilliant script – just love it! Thank you.

    One tiny problem, though.

    The script is set to call thumbnails and my WP media is set for thumbnails to be sized to width =150.

    My photos uploaded are already sized at 150, BUT your script is pulling the photos to 213 so everything is distorted.

    Any suggestions – thx again for the wonderful script.

  137. Martin
    Martin July 8, 2011 at 8:45 am | | Reply

    The idea is to click on a featured image and go to an external website as set in the image link box..!

  138. kyle
    kyle October 2, 2011 at 8:03 am | | Reply

    [...] Everything you need to know about WordPress 2.9′s post image feature [...]

  139. Holger Voss
    Holger Voss October 3, 2011 at 2:30 pm | | Reply

    Brilliant! Absolutely brilliant! Good explanation also for germans! Thanks a lot for that!

  140. read me | | Find a NannyFind a Nanny November 24, 2011 at 6:37 am |
  141. Stephen Crane
    Stephen Crane December 12, 2011 at 11:47 pm | | Reply

    So, I can’t get the “Post Thumbnail box” to appear in my theme. I placed the code :

    add_theme_support( 'post-thumbnails' );

    into my theme’s function.php file but it won’t show up in my posts panel. What am i doing wrong?

Leave a Reply

By submitting a comment here you grant this site a perpetual license to reproduce your words and name/Web site in attribution.

Please use your real name or a pseudonym (i.e., pen name, alias, nom de plume) when commenting. If you add your site name, company name, or something completely random, I'll likely change it to whatever I want.