WordPress Feature Images & Post Thumbnails

  • Feature Images (aka Post Thumbails)
  • Add support: add_theme_support( ‘post_thumbnails’ );
    • It is possible to enable this only for specific post types
  • add_image_size() – Defaults: thumbnail, medium, large, full size.
    • add_image_size( ‘category-thumb’, widepx, heightpx);
  • set_post_thumbnail_size() – Made by resizing proportionally or cropping
    • set_post_thumbnail_size( 50, 50 ); // by proportion
    • set_post_thumbnail_size ( 50, 50, true); // crop
  • has_post_thumbnail() – Check
  • the_post_thumbnail() – Display
  • get_the_post_thumbnail() – Retrieve
  • get_post_thumbnail_id()
  • Are automatically give a class of wp-post-image as well as one of: img.wp-post-image, img.attchment-thumbnail, img.attachment-medium, img.attachment-large, or img.attachment-full.
  • Can have a class associated with them:
    the_post_thumbnail( ‘thumbnail’, array( ‘class’ => ‘alignleft’ ) );