Total Post Thumbnail (Featured Image) Helper Functions

The Total theme has a built-in image resizing function that crops images only as needed instead of the core WordPress post thumbnail function which crops images to every defined size whenever you upload a new image. For this reason Total has it’s own helper functions for returning images in the theme which you can make use of in your child theme if needed/wanted.

Here is an example:

$thumbnail = wpex_get_post_thumbnail( array(
	'post'           => null,    // (int) Fetch thumbnail from a post.
	'attachment'     => '',      // (int) Fetch thumbnail from a specific attachment ID.
	'size'           => '',      // (string) Pre-defined thumbnail size name (thumbnail, medium, full).
	'width'          => '',      // (int) Custom width.
	'height'         => '',      // (int) Custom height.
	'crop'           => '',      // (int/string) Crop location.
	'return'         => 'html',  // (string) Function return html, url, src.
	'style'          => '',      // (string) Custom inline style attributes (padding:10px;).
	'alt'            => '',      // (string) Custom alt.
	'class'          => '',      // (string) Custom classnames.
	'before'         => '',      // (html/string) Content to add before the thumbnail.
	'after'          => '',      // (html/string) Content to add after the thumbnail.
	'attributes'     => array(), // (array) Custom html attributes.
	'add_image_dims' => true,    // (bool) Add width/height attributes?
	'schema_markup'  => false,   // (bool) Add schema markup?
) );

See Total/framework/post-thumbnails.php for this function reference.

More helper functions:

  • wpex_get_post_thumbnail_src( $args = array() ) - Same as the above function but returns the src without having to set the return parameter
  • wpex_get_thumbnail_sizes() - returns an array of all registered image sizes
  • wpex_featured_image_caption( $post_id ) - returns a caption for the featured image of any post
  • wpex_get_attachment_data( $attachment = '', $return = 'array' ) - returns the url, src, alt, title, caption, description or video for any image attachment ID.
  • wpex_get_lightbox_image( $attachment = '' ) - Returns the lightbox image variation for any image based on your lightbox image cropping sizes in the Image Sizes panel
  • wpex_placeholder_img_src() - Returns theme placeholder image