Broken images on email templates

Hello guys, I am using SBE plugin and when I receive an email notification for new posts, the images are broken. I get:

http:///wp-content/uploads/2016/08/image.jpg

Is there a way to add the domain name on sbe_show_featured_image() output?

Thanks in advance.

  • Adam Czajczyk

    Hello Robert,

    I hope you're well today and thank you for your question!

    I've tested this on my test setup with different e-mail accounts and the images does contain proper ULRs. I did however notice some issues related to how images are handled by various mail providers. For example, Google replace original domain with a "google proxy" URL. Some other providers do similar "tricks".

    That being said, in order to track down the issue and narrow down options I'd like to ask you what account (just an e-mail provider/domain) are you using and what way (via website e-mail inbox or an e-mail program/app - if so, which one) are you checking your inbox?

    Did you also checked that with various e-mail accounts coming from various providers? Let me know please.

    Best regards,
    Adam

  • Adam Czajczyk

    Hello Robert,

    Thanks for granting access!

    I checked your site and I can tell that this issue is not a bug or a glitch in Subscribe by Email plugin. The problem is that media URLs on your site doesn't include domain name. Please go to your Media Library and edit any of the images that you uploaded there. When you take a look at "File URL" filed you'll find out that its value doesn't start with "http://yourdomain...." but with just "/wp-content..." part.

    WP core functions return image URL "as it is" so since it doesn't include the domain name that returned URL doesn't include it either. Let's take a look at an example "img" HTML tag that's used to display images on your site and any other HTML formatted template:

    <img src="/wp-content/something/img.jpg">

    Browser by default will assume that the image file is located on the same domain that the HTML document comes from so it will append the "http://yourdomain.com" in front of "/wp-content..." string. Hence, this works fine on site.

    No other "viewer" - such as mail inbox - that is located "outside" of your domain will now what should be appended to img src and as a result won't be able to load image.

    The bottom line is: those "broken" images are because of how browsers work and the fact that your WP install doesn't put a domain name where it should (by default WordPress does append full URL to the media "File URL").

    I noticed that the "WordPress Address (URL)" and "Site Address (URL)" values on "Settings -> General" page of your site's dashboard are not editable. I think then that you may have modified your site's wp-config.php file slightly. Could you please share it with me?

    To do this, copy its contents to a ".txt" file, strip out all sensitive data (db credentials and keys) and post it here?

    Also, if you can think of any changes (related to the settings I mentioned above) that you ever made, let me know please. I think it's highly relevant to the issue.

    Best regards,
    Adam

  • Chamosan

    adam,

    Thanks for your help. I was able to comment out the following lines in the wp-config.php file:

    define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']);
    define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST']);
    define('WP_CONTENT_URL', '/wp-content');
    define('DOMAIN_CURRENT_SITE', $_SERVER['HTTP_HOST']);

    This allowed me to change the URL in the settings page and that resolved the image path issue. Thank you very much!