I have a maintained and working version of the plugin here: https://github.com/DeflateAwning/wp-plugin-Insert-Featured-Image-Shortcode
It seems that this plugin, as-is, doesn’t work and is unmaintained.
]]>Plesse add a attributable src to add featured image from url
there are many plugin to support remote(url based) featured image.But not one of them support shortcode
thank you in advance.
Although it’s old, it still works. However, as written, it expects a size and a class parameter. The small changes below remove that need.
/**
* Shortcode for post thumbnail
*/
function post_thumbnail_shortcode($atts, $content='') {
if(!function_exists('post_thumbnail_shortcode')) {
return;
}
if(empty($atts['size'])) {
$atts['size'] = 'thumbnail';
}
if(empty($atts['class'])) {
$atts['class'] = '';
}
return '<span class="post_thumbnail '.$atts['class'].'">'.get_the_post_thumbnail(null,$atts['size']).'</span>';
}
function post_thumbnail($str) {
$args = wp_parse_args($str);
echo post_thumbnail_shortcode($args);
}
add_shortcode('post_thumbnail', 'post_thumbnail_shortcode');
https://www.ads-software.com/plugins/add-post-thumbnail-shortcode/
]]>On line 17, you have:
if(!$atts['size'])
size might not be defined which triggers a warning telling you that your using an invalid offset. It should be replaced by:
if(empty($atts['size']))
which checks if it’s set first.
Thanks for the plugin.
https://www.ads-software.com/extend/plugins/add-post-thumbnail-shortcode/
]]>I’d like to have the option to allow the thumbnail to link to the image. I’m using this shortcode to place the featured image at the top of each page (my theme doesn’t support featured images), and I’d like to link to the full-sized image (to display with a lightbox).
https://www.ads-software.com/extend/plugins/add-post-thumbnail-shortcode/
]]>