summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Auditor2011-11-22 15:54:16 (GMT)
committer Stefan Auditor2011-11-22 15:54:16 (GMT)
commitddd447677b26fb92020bb05512bd6ba384f24460 (patch)
tree981fc303810ae45d3ad52f0a3f7942d55e097767
parente0785cb3fe118657ed2f2fe7248e2ae19ee833aa (diff)
rename cookie
-rw-r--r--adaptive_image.image.inc8
-rw-r--r--adaptive_image.module12
2 files changed, 13 insertions, 7 deletions
diff --git a/adaptive_image.image.inc b/adaptive_image.image.inc
index afba3e1..0ba7301 100644
--- a/adaptive_image.image.inc
+++ b/adaptive_image.image.inc
@@ -26,9 +26,9 @@ function adaptive_image_style_deliver($style, $scheme) {
}
/* Check to see if a valid cookie exists */
- if (count($resolutions) && isset($_COOKIE['adaptive-image'])) {
- if (is_numeric($_COOKIE['adaptive-image'])) {
- $client_width = (int) $_COOKIE['adaptive-image']; // store the cookie value in a variable
+ if (count($resolutions) && isset($_COOKIE['adaptive_image'])) {
+ if (is_numeric($_COOKIE['adaptive_image'])) {
+ $client_width = (int) $_COOKIE['adaptive_image']; // store the cookie value in a variable
/* the client width in the cookie is valid, now fit that number into the correct resolution break point */
rsort($resolutions); // make sure the supplied break-points are in reverse size order
@@ -40,7 +40,7 @@ function adaptive_image_style_deliver($style, $scheme) {
}
}
} else {
- setcookie("adaptive-image", "", time() -1); // delete the mangled cookie
+ setcookie("adaptive_image", "", time() -1); // delete the mangled cookie
}
}
diff --git a/adaptive_image.module b/adaptive_image.module
index 681ff9e..ee945ae 100644
--- a/adaptive_image.module
+++ b/adaptive_image.module
@@ -15,7 +15,7 @@
function adaptive_image_init() {
// No need for drupal behaviours, jquery compatibility wrapper nor ready event
// This is inline to prevent wait time while loading the script
- $js = "document.cookie = 'adaptive-image=' + Math.max(screen.width, screen.height) + '; path=/';";
+ $js = "document.cookie = 'adaptive_image=' + Math.max(screen.width, screen.height) + '; path=/';";
drupal_add_js($js,
// First-come, first-served
array(
@@ -147,8 +147,14 @@ function adaptive_image_preprocess_image(&$variables) {
// Check if style contains the adaptive image effect
if ($style && adaptive_image_contains_effect($style)) {
- // Reconstruct the image path to %/%style_name/adaptive-image/%
- $variables['path'] = str_replace('styles/' . $variables['style_name'], 'styles/' . $variables['style_name'] . '/adaptive-image', $variables['path']);
+ if (is_numeric($_COOKIE['adaptive_image'])) {
+ // Reconstruct the image path to %/%style_name/adaptive-image/%
+ $variables['path'] = str_replace('styles/' . $variables['style_name'], 'styles/' . $variables['style_name'] . '/adaptive-image', $variables['path']);
+ }
+ else {
+ // Reconstruct the image path to %/%style_name/adaptive-image/%
+ $variables['path'] = str_replace('styles/' . $variables['style_name'], 'styles/' . $variables['style_name'] . '/adaptive-image', $variables['path']);
+ }
$variables['attributes']['class'] = 'adaptive-image';
// Remove fixed image dimensions
unset($variables['height']);