Home / Admin / Increasing Image Size in Notification Emails
Duplicate Snippet

Embed Snippet on Your Site

Increasing Image Size in Notification Emails

With this PHP snippet, you can easily adjust the size of these images in larger sizes.

10+
Code Preview
php
<?php
/**
* How to Increase Image Size in Notification Emails
*
* @link https://wpforms.com/developers/how-to-increase-image-size-in-notification-emails
*/
function wpf_custom_wpforms_email_notification_message_thumbnail($message) {
    // Define the new width and height
    $new_width = 'auto';
    $new_height = 200;
  
    // Use preg_replace to modify the width and height of the image
    $pattern = '/<img([^>]*)width="(\d+)"([^>]*)height="(\d+)"([^>]*)>/';
    $replacement = '<img$1width="' . $new_width . '"$3height="' . $new_height . '"$5>';
    $message = preg_replace($pattern, $replacement, $message);
  
    return $message;
}
add_filter('wpforms_emails_notifications_message', 'wpf_custom_wpforms_email_notification_message_thumbnail');

Comments

Add a Comment