Thumbnail Field

Exposes two new functions theme developers can use to facilitate retrieving field information from a post's featured image

Author:Cornershop Creative (profile at wordpress.org)
WordPress version required:3.5.0
WordPress version tested:5.3.3
Plugin version:1.0.3
Added to WordPress repository:17-05-2014
Last updated:12-11-2019
Warning! This plugin has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.
Rating, %:0
Rated by:0
Plugin URI:http://cornershopcreative.com/code/thumbnail-...
Total downloads:997
Active installs:10+
plugin download
Click to start download

Thumbnail Field’s purpose is simple and straightforward: It creates two new functions, the_thumbnail_field() and get_thumbnail_field(), to facilitate retrieving information from a post’s featured image, such as the title, alt, description, or caption. Theme and plugin developers are welcome to strip these functions out of this plugin and use them directly in their work, or require this plugin.

In keeping with WordPress style, the_thumbnail_field() echoes the field value, whereas get_thumbnail_field() merely returns it.

Both functions take up to three arguments, all of which are optional:

  • $field is the name of the field to retrieve. Defaults to ‘caption’. Custom meta fields are supported.
  • $post_id is an integer specifying the ID of the post to retrieve featured image information for. Defaults to current $post
  • $suppress_filters is a boolean TRUE|FALSE value indicating whether to run the returned field through get_thumbnail_field filters that might be defined somewhere. Defaults to false. Note that this plugin provides this filter hook as a courtesy but does not use it; out of the box this setting will therefore have no effect.

Thus, outputting the description for the featured image of post ID 45 would look like this:

<?php the_thumbnail_field( 'description', 45 ); ?>

Installing this plugin will make no visible changes to your WordPress admin.