Gmail – Render images with non-public URL in body of Gmail message

gmailimagesPROXY

With Gmail's recent change to serve all images through a proxy, it appears that it is no longer possible to embed an image that is served up via a localhost URL. For example, as a developer, I used to be able to send an email to myself with content like:

<img src="http://localhost/trackthismessage?readby=xxxx" />

and, upon telling Gmail to display images, the image would be served up by my local development machine.

Now, with the proxy in the middle, it seems this is no longer possible. Is this functionality now just gone or is there a workaround?

Best Answer

There is actually a workaround for developing. Just run this in your JS console and the images will appear. Found this on Stack Overflow. Make sure you choose 'Display Images' on the message first

(function(){ while(img = document.evaluate('//img[contains(@src, \'googleusercontent.com\')]', document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue){ var src = img.attributes.src.value; src = src.substr(src.indexOf('#')+1); img.attributes.src.value = src; } })();

You can also create a bookmark for increased handiness prefixing the above with javascript:

javascript:(function(){ while(img = document.evaluate('//img[contains(@src, \'googleusercontent.com\')]', document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue){ var src = img.attributes.src.value; src = src.substr(src.indexOf('#')+1); img.attributes.src.value = src; } })();