Cropping image in html without using div

493 Views Asked by At

I am working on an email integration. I know that the div tag are not well interpreted on various platform (some outlook version, some webmails, etc).

My problem : I want to crop unkown size image... Without using the div tag (so with table...) ! Do you think it is possible ?

Thanks ! Stef

2

There are 2 best solutions below

0
On

Since this question is specific to email. There is no way to do this across email clients, unless you are only supporting clients like Apple Mail, which of course is not a good idea.

Outlook Desktop client will ignore any size adjustment on an image and show its actual size. I think Outlook.com does this too.

If you're pulling in an unknown image, is this email being generated by a script or RSS? If so, there might be ways to adjust the image before it gets to the email using PHP or other languages that support image manipulation. But that is beyond the scope of this question.

Bottom line, it's not possible to do this in HTML Email. Like others have said, if you can, just crop the image to the size you need before putting it in the email.

0
On

There is no real guaranteed to work way to crop images in HTML emails. The closest would be to use as a background image with the container a declared width/height smaller then the actual size. The issue is some clients may not only ignore this and display full size, but others may instead warp the image to fit the size of the container listed.

Your best bet is to manually crop it to the correct size beforehand and assume HTML/CSS resizing will not work (thanks Outlook), but I know sometimes with automated templates this is not an option. Your other choice in finding a solution is trial and error using this CSS guide and a testing site like Email on Acid. Using data collected from your past emails I would find your most popular email clients and devices and try to maximize for those. You will likely have to be willing to provide a broken email to that smaller portion of your audience as well.