title: How to prevent auto-rotating images on iOS on HTML with CSS/Javascript
body: <p>I am creating a photo site - I uploaded a photo of myself which is actually incorrectly oriented (the image is rotated 90 degrees counter clockwise). I have uploaded this image from my iPhone, which apparently has the image stored this way on purpose.</p>
  
  <p>On my site, the HTML page has rendered a JSON object that contains the URL to the photo as well as the image dimensions. I am using jQuery mobile - and onload of the page I put a link on the page, and when you click the photo it displays the photo as a popup. The popup renders an <code>&lt;img&gt;</code> tag with dimensions that are small enough to fit the image within the current viewport width/height. It calculates the dimensions using the JSON I previously mentioned, and the results from <code>$(window).width()</code> and <code>$(window).height()</code>.</p>
  
  <p>On desktop - the photo correctly displays in the wrong orientation (because that is how the photo is actually stored).</p>
  
  <p>On iPad &amp; iPhone - the photo is auto-rotated so the photo is correctly oriented, but the dimensions are all wrong so the photo is all stretched out and distorted.</p>
  
  <p>I would like to know the following:</p>
  
  <ol>
  <li>Is this a commonly known feature of browsers on iOS or other devices?</li>
  <li>Is there a way to disable this functionality using CSS or Javascript?</li>
  <li>Is there a way to detect that it happened and correct the dimensions of the <code>&lt;img&gt;</code> tag? I don't mind that the photo's orientation was corrected by the browser, I just want the dimensions to be proper.</li>
  </ol>
  
  <p><em>EDITS</em></p>
  
  <p>Making the Title more in the form of a question - Also reformulating the question to be more direct</p>
  
  <p><em>MORE EDITS</em></p>
  
  <p>Here is a JS Fiddle with an example: <a href="http://jsfiddle.net/5JKgn/" rel="nofollow">http://jsfiddle.net/5JKgn/</a></p>
  
  <p>If you click the link on a desktop computer, the popup shows the image improperly oriented. If you click the link on an iPhone or iPad, the popup shows the image properly oriented, but the dimensions are wrong so the photo is stretched.</p>
  
  <p>In the real scenario, the JSON is rendered by PHP code which can read the image and outputs the width height from what it gets using <code>getimagesize()</code></p>