How to handle thumbnails

How should I handle post thumbnails? Do most people put them in custom fields? Use a plugin? How do themes on ThemeForest handle this?

Also different theme will have different size requirements? So moving from 1 theme to the next could cause alot of problems?

Read More

Thumbnails may come in different sizes too

Related posts

Leave a Reply

2 comments

  1. Since WordPress 2.9, you can add thumbnail support to your theme by adding this to the theme’s functions.php file:

    if ( function_exists( 'add_theme_support' ) ) { 
      add_theme_support( 'post-thumbnails' ); 
    }
    

    When this is done, you’ll be able to add a feature image to your post on Posts, Pages or Custom Post Types. You’ll see the “Featured Image” box when creating a new post.

    You can set the thumbnail size also in your functions.php file. You can use WordPress’ “thumbnail”, “medium” and “large” sizes, create your own or specify a size with pixels:

    the_post_thumbnail('thumbnail');       // Thumbnail (default 150px x 150px max)
    the_post_thumbnail('medium');          // Medium resolution (default 300px x 300px max)
    the_post_thumbnail('large');           // Large resolution (default 640px x 640px max)
    
    the_post_thumbnail( array(100,100) );  // Specify resolution
    //Add your own:
    add_image_size( 'category-thumb', 300, 9999 ); //300 pixels wide (and unlimited height)
    

    Example of how to use this new Post Thumbnail size in theme template files.

    <?php the_post_thumbnail( 'category-thumb' ); ?>
    

    You should check Codex’s page on Post Thumbnails for more info. There you’ll also find how to style your thumbnails and more details on this code.

  2. Thumbnail handling is basically combination of two factors – standards and meta information.

    1. Native post thumbnails are standard and have meta info.
    2. Custom fields can hold meta info about thumbnail, but there is no standard.
    3. Post content can be mined for images (no meta, no standard).
    4. Something really custom, like assigning thumbnails depending on post categories, etc.

    If you have control over content form the start it is easier to choose some method and stick with it. If you don’t have control or content predates post thumbnails it is more tricky. Personally I use Get The Image that is single wrapper to run multiple methods to fetch thumbnail (with your own callback if needed).