IPhone image size 480? #78

Closed
bworby opened this Issue Oct 4, 2012 · 3 comments

Projects

None yet

3 participants

@bworby
bworby commented Oct 4, 2012

I have a question more than an issue. But anyways I set it up with an additional 320 in
$resolutions = array(1382, 992, 768, 480, 320);

Now when I visit on my iphone the images get resized to 480. Shouldn't this be 320 to fit the screen?

I see
$resolution = $is_mobile ? min($resolutions) : max($resolutions);

which ultimately should return the 320, and I checked and the size is 320 by 480.

Anyone else see this issue?

I just tried on ipad and get same result, its creating the images based on the height not width of screen. But if I turn on your error reporting, mobile is true?

@bworby
bworby commented Oct 5, 2012

So i added this to the bottom of the file
$testRes = $is_mobile ? min($resolutions) : max($resolutions);
sendErrorImage("testRes is :" . $testRes . " And resolution is :" . $resolution );

and I get
testRes is:320 And resolution is:480

This is after a fresh cleaning of cookies, and cache. Am I wrong to be expecting 320?

@agorilla

The device resolution detection is done with JS. It creates a session cookie which then is processed in the adaptive-images.php.

<script>document.cookie='resolution='+Math.max(screen.width,screen.height)+'; path=/';</script>

It consideres both portrait and landscape mode as the higher value of screen width and height is used. In case of an iPhone that's 480 pixel. Otherwise the images would need to be scaled up by the browser in landscape mode.

But there is a commit to detect the orientation of the device on page load: mpecan@154056e

Of course when you then switch from portrait to landscape mode, the images need to be scaled up by the browser which results in quality loss.

@MattWilcox
Owner

Hi, sorry for the late reply!

Yes, you'd be wrong to expect the 320. AI goes off the largest screen dimension, not the one that's currently the width. It does this to avoid problems with browser caches. Imagine you view a page in portrait at 320. With the behaviour you expect it would download a 320px wide image and cache it. Now rotate your device and it needs a 480px image. But it won't request one, because there's one in the cache. At the wrong size.

The filesize difference between 320 and 480 is small, so it's not too big a problem.

I haven't (and will not) roll in the "Device Orientation" patch because it would result in this problem. The "patch" is a defect, not an enhancement.

@MattWilcox MattWilcox closed this Oct 17, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment