Featured Image Shortcode

,

Usage:


[featured-image size = "large" class = "featured-image" title = "something" alt = "image"]


Available attributes:
  • class
  • title
  • alt
Available sizes:
  • thumbnail
  • medium
  • large
  • full

and add the following code in your functions.php file

add_shortcode('featured-image', array('Featured_image_shortcode', 'cvf_post_thumbnail_shortcode') );

class Featured_image_shortcode {

public static function cvf_post_thumbnail_shortcode($atts, $content = '') {

$img_attr = '';
$atts['class'] = '';

$img_attr = array(
'class' => $atts['class'],
'alt' => trim(strip_tags($atts['alt'])),
'title' => trim(strip_tags($atts['title']))
);

if(!$atts['size']){
$atts['size'] = 'thumbnail';
}

return get_the_post_thumbnail(null, $atts['size'], $img_attr);
}
}




Related Post


Latest Post


Recent Posts Widget

Make sure to never miss a thing...

Get the latest news from the creative industry along with other creative goodies, conveniently delivered to social media.