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:||4.9|
|Added to WordPress repository:||17-05-2014|
Click to start download
- Upload the
thumbnail-fielddirectory to your plugins directory (typically wp-content/plugins)
- Activate the plugin through the ‘Plugins’ menu in WordPress
- Use code like
<?php if ( function_exists('get_thumbnail_field') ) get_thumbnail_field(); ?>or
<?php if ( function_exists('the_thumbnail_field') ) the_thumbnail_field(); ?>in your templates
What fields can I retrieve from this plugin’s functions?
This can retrieve the following information from a post’s featured image, all of which are considered ‘fields’ for the purposes of passing the first argument to one of the functions:
- author (ID of the user who uploaded the attachment)
- uploadedTo (the post ID it was first attached to, I think?)
- sizes (an array of all the sizes the image exists in)
What about custom fields?
No problem. If the field you’re interested in isn’t one of WordPress’s defaults but is defined as a standard meta field, this should be able to grab it.
What about multi-fields?
Mostly this plugin assumes fields will have single, textual values. But you may have a custom field, or be fetching a built-in key such as ‘sizes’, that isn’t. Not to fear! This will happily return a maybe-unserialized array for you if it finds something of that sort. In these cases, using
the_thumbnail_field() will be pretty useless — you’ll want to use
get_thumbnail_field() to fetch the array and manipulate/echo values within it.
Changing authorship credit and implementing plugin icon for WP >= 4.0
Initial release, includes got the_ and get_ versions of functions and support for meta fields.