Outlook and Email Image Resizing

Oh Outlook… how I despise you. As we’ve been fine-tuning our email templates, we noticed that whenever anyone opened our emails in Outlook, the images were full size despite the setting of the height and width of our email images. So frustrating… but there’s as with everything else in WordPress, there’s a workaround!

Within our theme functions.php file we added new image sizes that we will be utilizing within our email templates. This ensures that all of our images, when uploaded, are cropped to the sizes we define:

if ( function_exists( 'add_image_size' ) ) {
add_image_size( 'email-lg', 600, 300, true );
add_image_size( 'email-md', 260, 260, true );
add_image_size( 'email-sm', 90, 90, true );

The next step is to regenerate the thumbnails now that they’re applied in my theme using the Regenerate Thumbnails WordPress plugin. Now, when I utilize the function in my CircuPress email template to apply the image, the cropped image will be referenced. The code is:

<?php if ( has_post_thumbnail() ) {
$src = wp_get_attachment_image_src( get_post_thumbnail_id( $events->ID, 'email-lg' ), array(600,300) ); ?>
<img src="<?php echo $src[0]; ?>" style="width:100%;" />
<?php } ?>

Notice the reference to the image size within the get_post_thumbnail_id call!

Leave A Comment?

You must be logged in to post a comment.