WordPress.org

Ready to get started?Download WordPress

Forums

MailPoet Newsletters
[resolved] Changing the size of images in automatic created emails (11 posts)

  1. prokopino
    Member
    Posted 1 year ago #

    Greetings
    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!

    http://wordpress.org/extend/plugins/wysija-newsletters/

  2. Ben
    Member
    Plugin Author

    Posted 1 year ago #

    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,
    Cheers!
    Ben

  3. owcv
    Member
    Posted 1 year ago #

  4. Manuel Schmalstieg
    Member
    Posted 1 year ago #

    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.

  5. gilnamur
    Member
    Posted 1 year ago #

    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
    TITLE
    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.
    Cheers,
    Gil

  6. Manuel Schmalstieg
    Member
    Posted 1 year ago #

    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 :)

  7. Dalton
    Member
    Posted 11 months ago #

    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.

  8. nathanwells
    Member
    Posted 11 months ago #

    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.

  9. mdviky87
    Member
    Posted 11 months ago #

  10. MailPoet Staff
    Member
    Plugin Author

    Posted 11 months ago #

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

  11. Manuel Schmalstieg
    Member
    Posted 10 months ago #

    @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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic