Support » Plugin: MailPoet 2 » Changing the size of images in automatic created emails

  • Resolved prokopino


    The BEST newsletter (and more…) plugin i have ever found!

    Everything is working great, but becausei heve many posts in my email, I must change the size of images (in automatic created mails)

    So, my question is how can i change the size of images included in automated created emails. In which files I must make changes and What?

    Thank you for your help and for your great plugin!

Viewing 10 replies - 1 through 10 (of 10 total)
  • Hello,

    First thing, thanks for the kind words. It’s always nice and encouraging to read them 🙂

    Now regarding your issue, there is no solution at this time, we’re working on getting a smaller version that fits the dimension of a standard newsletter, but that’s for one upcoming version, not yet there. I guess you could do it by hacking our plugin though, check out the file : wysija-newsletters/helpers/articles.php

    Hope this helps,

    I encountered the same issue – not with automatic mails, but when inserting a blog post into the newsletter body.

    I was told by the awesome support team that it’s “one of the most important thing to be improved”, and should be fixed in the near future.

    However, Wysija being open source software, I had a look at the inner workings of the plugin, to see if I could maybe come up with a fix. And – surprise! – here we go:

    Using version 2.5.4, in the file helpers/articles.php,
    at line 209, you should see this:

    $image_info = wp_get_attachment_image_src($post_thumbnail, 'single-post-thumbnail');

    Actually, that single-post-thumbnail value should refer to a registered image size, but for some reason, it has never been defined. Therefore WordPress simply ignores it, and wp_get_attachment_image_src() outputs the “full” image instead.

    The Solution:

    Replace “single-post-thumbnail” with an existing image size. That could be “large” (defaulting to 1024px wide) or “medium” (defaulting to 300px wide), or “thumbnail”, or some custom image size that you would define with add_image_size().

    Or we can use the custom size that is already defined by Wysija, named “wysija-newsletters-max”, which is 600px wide. It’s being used when you insert an image into the newsletter from the “Images” tab, in the editor sidebar.

    This sounds good to me, knowing that the actual image size in the newsletter will be 325 px wide, and taking in account retina screens, we should use a slightly wider image. Also, I don’t want to register a gazillion of additional custom image sizes, so let’s reuse this one.

    So my changed line looks like this:

    $image_info = wp_get_attachment_image_src($post_thumbnail, 'wysija-newsletters-max');

    I hope this helps for now, and will allow our end users to send their awesome newsletters with decently sized images, until we get an official fix from the Wysija team.

    Hi Manuel,

    That’s great! I just tried it on our weekly digest and it works. I used an existing image size (110 x 110)

    Note: It fails on a per article basis if that article does not have a ‘featured image’ set. The digest will show the right size (110 x 110) for all articles that do but uses the original image for articles that do not have a featured image set.

    So I just updated the 2 articles that did not and it works perfectly.

    Now if only I could get them to add in the byline
    By – Author

    We are a multi author blog (150+ authors) and we really need to show their names in the digest. I think I will noodle a bit with this php file and see where I get 😉

    Again, THANK YOU!!! Great stuff.

    Hi Gilnamur,

    Thanks for that feedback, great to know that my trick is useful for others.

    Your use case sounds interesting, make sure that you post your solution when you find it 🙂

    Rather than edit the plugin (which will be overwritten the next time you upgrade) just add this to your theme’s functions.php:

    function custom_after_theme_setup() {
        add_image_size( 'single-post-thumbnail', 600, 600, false );
    add_action( 'after_setup_theme', 'custom_after_theme_setup' );

    You may need to “regenerate thumbnails” afterwards to create the image sizes.

    Thanks for the code – I added the single-post-thumbnail size to my functions.php and it worked great! Hopefully this feature will be added in the future, but until then, this works.

    I want email like this

    Is there a way to increase width of email. so i can add three columns. Can i create my email template

    Plugin Author MailPoet


    Hello mdviky87. If you have another question, please post a new thread. Otherwise, it gets confusing for everybody.

    @dalton indeed, the only reason I didn’t consider this is that I expected the Wysija team to fix this issue quickly, and didn’t want to overload my install with additional image formats.

    But this hasn’t been corrected in the last few updates, so in the meantime your solution is the best.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Changing the size of images in automatic created emails’ is closed to new replies.