Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a method of turning off the Gmail App's Auto-resize feature in an email's layout?

I'm laying out an email to be viewed across browsers and mobile platforms and mostly all is going well. It's laid out in tables, using inline styling etc. However, despite a media-query to the effect of a 600px max-width, the Gmail app on at least my and one other Android I have access to is opting to resize the images and layout to fit into it's area instead of using the media query or letting it fit itself into the window normally, either of which would be fine.

For personal use, I'm able to 'turn off auto-resize' on my phone, and then the email lays out as it would in a browser.

Is there a means to either tell the Gmail app not to auto-resize from the email size or to use the media query instead?

like image 597
Abernasty Avatar asked Aug 22 '13 19:08

Abernasty


People also ask

How do I stop Gmail from resizing photos?

The gmail app offers no options, no preferences in settings and does not ask before sending the email if you want it compressed/resized or to send original. There is no way to attach an image in the gmail app. Gmail in mobile web browser only attaches images and doesn't offer inline images.


2 Answers

As Google does itself (sic!) here you should add a small hack on top of your template, right after your <body> tag:

<!-- Gmail hack -->
<div style="display:none; white-space:nowrap; font:15px courier; color:#ffffff; line-height:0; width:600px !important; min-width:600px !important; max-width:600px !important;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
<!-- /Gmail hack -->

Since Gmail and Inbox will ignore the display:none, the hack will affect only those two clients.

like image 146
Matteo Antoci Avatar answered Oct 05 '22 02:10

Matteo Antoci


<meta name="viewport" content="width=device-width, initial-scale=1"/>

Then set the style attribute on an image (1px gif works) that spans the full width of the page (style="min-width:600px;"). Everything will be laid out correctly, and it'll be scrollable.

Gmail in general doesn't support media queries, or the style tag in general, which is why we have to move everything inline.

like image 36
zazzyzeph Avatar answered Oct 05 '22 01:10

zazzyzeph