Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

DOIN' THANGS.

  • Loading branch information...
commit e228db6f0a44e7df532fc510916e0b081d351ced 1 parent e0c7bfe
@Wilto authored
Showing with 6 additions and 7 deletions.
  1. +4 −0 images/img.php
  2. +1 −2  index.html
  3. +1 −5 readme
View
4 images/img.php
@@ -76,7 +76,11 @@ function resize($target, $path, $view, $type) {
$image = $rwd->resize($image, $path, $view, $type);
}
+ header("Cache-Control: private, max-age=10800, pre-check=10800");
+ header("Pragma: private");
+ header("Expires: " . date(DATE_RFC822, strtotime(" 2 day")));
header("Content-Type: image/$type");
+
print $image;
imagedestroy($image);
?>
View
3  index.html
@@ -9,11 +9,10 @@
<script type="text/javascript">
(function() {
var date = new Date(),
- max = (screen.availWidth > screen.availHeight ) ? screen.availHeight : screen.availWidth;
+ max = (screen.availWidth > screen.availHeight ) ? screen.availWidth : screen.availHeight;
date.setTime(date.getTime() + (1 * 24 * 60 * 60 * 1000));
document.cookie = 'rwd-viewport = ' + max + '; expires = ' + date.toGMTString() + '; path = /';
-
})();
</script>
View
6 readme
@@ -2,10 +2,6 @@ Spent today messin’ around with responsive images, and thought I might try a b
So, the basic idea is that the .htaccess file intercepts the request for the image file and forwards the path along to img.php, which potentially generates and caches a smaller version of the image depending on the screen size set in the ‘rwd-viewport’ cookie via JS.
-Obviously this is still rough. Couple of notes:
-
-I'm just resizing to 25% on smaller screen sizes because it was the first thing that came to mind, but that should probably be a little more... User-settable. Also, images should never be resized to larger than the device's screen width—there's no need to only restrict us to "small" and "large" images with this approach, right?
-
-Should it generate and store the images on the server for access later? Let us think on this.
+Said cookie is set to the greater of the device's height or width, to allow for full-bleed images regardless of device orientation.
Here's the big thing: I'm not sure how I feel about delivering the mobile images to users with cookies disabled. Granted it's a better approach than potentially throwing monster images at users on a Nokia 6230, but... Still, there has to be some way of providing a fall-back method for passing the viewport information along to the backend.

0 comments on commit e228db6

Please sign in to comment.
Something went wrong with that request. Please try again.