Newsletters: Post Thumbnail Shortcode
You can insert a post thumbnail or featured image into a newsletter with the WordPress Newsletters plugin.
The shortcode ultimately calls the WordPress functions
the_post_thumbnail() to generate an image with a link to the post. In order to use this shortcode successfully, your WordPress theme (or a 3rd party plugin) has to define WordPress featured images so that it can be used.
Use this shortcode to display the featured image or thumbnail of a post:
Several attributes can be specified on the shortcode to customize the look and feel of the post featured image generated in the newsletter.
post_id= X – Optionally specify a post_id to use the featured image of a specific post otherwise the current post will be taken automatically.
align= left | center | none | right – Specify the alignment of the image, it adds an HTML allign attribute to the image tag. Perfect for emails.
hspace= X – Specify the spacing around the image in pixels. An HTML hspace attribute with the value of X is added to the image tag.
size= thumbnail | large | medium | *custom* | X,Y – The size of the thumbnail image to show. By default, thumbnail is used but you can specify any predefined WordPress image size or a custom defined image size or alternatively a with width and height, comma separated eg. 300,200;
Here are some examples:
Left Aligned Thumbnail with Spacing
Large, Centered Image
Auto and Manual Post Thumbnail
In most places, the post thumbnail shortcode automatically generates the desired image.
Posts Shortcode, Latest Posts and Send as Newsletter
The image can be automatically populated for the current posts loop when you use
[newsletters_posts...] shortcodes as well as Latest Posts Subscriptions and the Send as Newsletter feature where a post, page or custom post is sent as a newsletter.
So for these shortcodes and features, the thumbnail is automatically generated with a simple shortcode and no
post_id attribute is needed.
Custom Post Thumbnail
Outside of the posts loop, you can also generate a post thumbnail or featured image for any post of your choice. You just have to specify the
post_id attribute in the shortcode additionally. Like this:
Filtering the Post Thumbnail Output
There are some filter hooks you can use to change the way post thumbnails are displayed in newsletters.