1

I want to do something like this inside a Twig template:

<img src="{{ img_path }}/logo.jpg" />

and send it with a mailer function (not mailto).

The {{ img_path }} is correct, because if I add:

<p>{{ img_path }}</p>

It is shown correctly (http://siteURL/img). And if I add /logo.jpg and put it on the URL, I'm getting the image.

But in the email, the image src attribute is a Google URL (I'm using Gmail to send) and the desired URL after that (https://ci5.googleusercontent.com/proxy/somecharacters#http://siteURL/img/logo.jpg), so the image is not showing.

Any idea of what is happening here and how to solve it?

4
  • I forgot to say that I'm working on my localhost. This could be the problem. Commented Feb 17, 2014 at 18:08
  • You might be using a relative path. Instead, try setting {{ img_path }} to the absolute URL. Commented Feb 17, 2014 at 18:08
  • @dward - It's not a relative path, but it's maybe because I'm working on localhost, and Google can't access it, because I've seen more images with a similar URL in some emails. Commented Feb 17, 2014 at 18:11
  • Maybe try installing a local mail catcher, like smtp4dev, and see if you can capture the mail locally and see it works correctly (or with different results). You'd think that if the URL is absolute, then it would show as "localhost". Also, you might check your open/closing tags as well as any concatenation strings you have in your app. Commented Feb 17, 2014 at 18:17

1 Answer 1

2

Recently (December 2013) Gmail started caching all images. It was a trade off as now images load by default, but they are hosted by Google's Proxy server, not your original URL.

Sounds like this caching is applying to your outbound email also.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.