Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Various updates
  • Loading branch information
MattWilcox committed Nov 10, 2011
1 parent 8e03f9d commit 8cd085a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .htaccess
Expand Up @@ -9,9 +9,13 @@
# RewriteCond %{REQUEST_URI} !and-ignore-this-directory-too

RewriteCond %{REQUEST_URI} !assets

# don't apply the AI behaviour to images inside AI's cache folder:
RewriteCond %{REQUEST_URI} !ai-cache

# Send any GIF, JPG, or PNG request that IS NOT stored inside one of the above directories
# to adaptive-images.php so we can select appropriately sized versions

RewriteRule \.(?:jpe?g|gif|png)$ adaptive-images.php

# END Adaptive-Images -------------------------------------------------------------------------------
Expand Down
11 changes: 6 additions & 5 deletions adaptive-images.php
Expand Up @@ -18,7 +18,7 @@
$sharpen = TRUE; // Shrinking images can blur details, perform a sharpen on re-scaled images?
$watch_cache = TRUE; // check that the responsive image isn't stale (ensures updated source images are re-cached)
$browser_cache = 60*60*24*7; // How long the BROWSER cache should last (seconds, minutes, hours, days. 7days by default)
$mobile_first = TRUE; // If there's no cookie sends the mobile version (if FALSE, sends largest $resolutions version)
$mobile_first = FALSE; // If there's no cookie sends the largest $resolutions version (if TRUE, sends smallest)

/* END CONFIG ----------------------------------------------------------------------------------------------------------
------------------------ Don't edit anything after this line unless you know what you're doing -------------------------
Expand Down Expand Up @@ -161,12 +161,13 @@ function generateImage($source_file, $cache_file, $resolution) {
ImageDestroy($src);

// sharpen the image?
if ($sharpen == TRUE) {
// NOTE: requires PHP compiled with the bundled version of GD (see http://php.net/manual/en/function.imageconvolution.php)
if($sharpen == TRUE && function_exists('imageconvolution')) {
$intSharpness = findSharp($width, $new_width);
$arrMatrix = array(
array(-1, -2, -1),
array(-2, $intSharpness + 12, -2),
array(-1, -2, -1)
array(-1, -2, -1),
array(-2, $intSharpness + 12, -2),
array(-1, -2, -1)
);
imageconvolution($dst, $arrMatrix, $intSharpness, 0);
}
Expand Down
12 changes: 12 additions & 0 deletions changelog.txt
@@ -1,3 +1,15 @@
version 1.3.4 (2011/11/10) ------------------------------------------------------------

BUG FIXES
* The sharpening function broke on libraries not compiled with the bundled version
of PHP. It now tests the imageconvolution function is available and gracefully
handles cases where it isn't.

NOTES
* Set $mobile_first to default to FALSE. Browsers are inconsistent with their
ability to set cookies before requesting <img>s. For more information visit
http://blog.yoav.ws/2011/09/Preloaders-cookies-and-race-conditions

version 1.3.3 (2011/10/18) ------------------------------------------------------------

BUG FIXES
Expand Down

0 comments on commit 8cd085a

Please sign in to comment.