Mauserrifle.nl Tech and Life

    Home     Archive     Projects     Contact

Gmail Not Showing HTML Image

When gmail is not showing a html image, make sure to check the following things.

1. It is public

Check whether the image can be loaded from another location than your own IP. For example you could check it using your mobile (disable wifi), ask a friend or check it using ssh on a remote server.

Example

curl -I https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png

When the server responds with a 200 http status code, you are good to go.

2. The src attribute does not contain newlines and spaces

Make sure the URL within the src attribute does not contain any newline or space. Even a newline just before the ending quote could stop gmail from loading the image. Oddly, sometimes an image url with newlines does load after clicking the option: [Message clipped] View entire message.

Wrong (newline):

<img src="https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png
">

Good:

<img src="https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png">

3. It has a width and height attribute

Make sure to add the width and height attributes to the image.

<img width="185" height="60" src="https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png">

4. It has an alt and title attribute

Try adding the alt and title attributes.

<img src="https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png" width="185" height="60" title="Google logo" alt="Google logo">


Hope this helps!

If you liked this post, you can share it with your followers!