css - Autoscale image in HTML table -


I am generating an HTML string for an email. I have something that looks like: < Pre> & lt; Td> & Lt; Img src = 'whatever.jpg' width = '100' style = 'float: left' /> & Lt; / Td>

The problem with this is that when the width is equal to the rows, then some rows are super long or super short based on the original image size. I can fit it into the 100x100 bounding box which I want to scale the image, while I tried to preserve aspect ratio:

   & Lt; Img src = 'whatever.jpg' width = '100' height = '100' style = 'float: left' /> & Lt; / Td>   

But it destroys the basic aspect ratio. I have also tried to determine the height of the TD element, but it seems that it has no effect.

While generating HTML it is not really possible to load and check the image size, because I am not in control of images and they can change.

OK, so you have to take back your needs in one corner.

  1. Really use an external service to resize the image, thereby eliminating the possibility of image click tracking, as long as you create your own convenience Can not go on (Enjoy this, the code that runs my company's click tracker alone

  2. Emails do not javascript, so throw away all those ideas < / Li>

  3. Can not support Outlook 7 and many other common commands View the float (go figure)

    The obvious answer is to combine html for ImageMagic or GD sender, but you said in your reply that You are not under the control of images and this is not possible when HTML is loading I think you are either of the options or you have to go back to the external service solution here: On the plus side, throwing the URL on the resize To make things happen, the website, and This will toss you back a valid resized image. Not terrible.

Comments