summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStella Power2008-02-12 19:56:16 (GMT)
committer Stella Power2008-02-12 19:56:16 (GMT)
commit35f198ce112e00dd8b0c9a5161c68bce1fe7c894 (patch)
tree7207006659a7217fa9708fe323dd88d2dcfdd409
parentd97c03c628f80e67a87fb90d97a966339dc08732 (diff)
#217069 (part 2) - added in ability to check for original images when the
designated display size for an image node isn't found. If it can't find the original then it will default to brokenimage.jpg.
-rw-r--r--js/image_nodes.js2
-rw-r--r--js/lightbox.js17
-rw-r--r--lightbox2.module5
3 files changed, 20 insertions, 4 deletions
diff --git a/js/image_nodes.js b/js/image_nodes.js
index 5770151..c1afb41 100644
--- a/js/image_nodes.js
+++ b/js/image_nodes.js
@@ -58,7 +58,7 @@ function lightbox2_image_nodes() {
// Set the href attribute.
else {
- href = $(child).attr("src").replace(".thumbnail", ((settings.display_image_size == "")?settings.display_image_size:"."+ settings.display_image_size)).replace(/(image\/view\/\d+)(\/\w*)/, ((settings.display_image_size == "")?"$1/_original":"$1/"+ settings.display_image_size));
+ href = $(child).attr("src").replace(new RegExp(settings.trigger_image_sizes), ((settings.display_image_size == "")?settings.display_image_size:"."+ settings.display_image_size)).replace(/(image\/view\/\d+)(\/\w*)/, ((settings.display_image_size == "")?"$1/_original":"$1/"+ settings.display_image_size));
}
// Modify the image url.
diff --git a/js/lightbox.js b/js/lightbox.js
index b928466..720a51d 100644
--- a/js/lightbox.js
+++ b/js/lightbox.js
@@ -29,6 +29,7 @@
* - updateImageList()
* - start()
* - changeImage()
+ * - imgNodeLoadingError()
* - imgLoadingError()
* - resizeImageContainer()
* - showImage()
@@ -341,7 +342,7 @@ var Lightbox = {
// if image is NOT part of a set..
if ((imageLink.rel == 'lightbox')) {
// add single image to imageArray
- Lightbox.imageArray.push(new Array(imageLink.href, imageLink.title));
+ Lightbox.imageArray.push(new Array(imageLink.href, imageLink.title));
}
else {
@@ -407,7 +408,7 @@ var Lightbox = {
$('#bottomNavZoom').hide();
imgPreloader = new Image();
- imgPreloader.onerror = function() { Lightbox.imgLoadingError(this) };
+ imgPreloader.onerror = function() { Lightbox.imgNodeLoadingError(this) };
// once image is preloaded, resize image container
if (zoom == "TRUE") {
@@ -454,6 +455,18 @@ var Lightbox = {
}
},
+ // imgNodeLoadingError()
+ imgNodeLoadingError: function(image) {
+ var settings = Drupal.settings.lightbox2;
+ var original_image = Lightbox.imageArray[Lightbox.activeImage][0];
+ if (settings.display_image_size != "") {
+ original_image = original_image.replace(new RegExp("."+settings.display_image_size), "");
+ }
+ Lightbox.imageArray[Lightbox.activeImage][0] = original_image;
+ image.onerror = function() { Lightbox.imgLoadingError(image) };
+ image.src = original_image;
+ },
+
// imgLoadingError()
imgLoadingError: function(image) {
var settings = Drupal.settings.lightbox2;
diff --git a/lightbox2.module b/lightbox2.module
index d12f892..4adf6ba 100644
--- a/lightbox2.module
+++ b/lightbox2.module
@@ -424,11 +424,13 @@ function lightbox2_add_files() {
$image_node_classes .= "img.flickr-photo-img,";
}
$trigger_sizes = variable_get('lightbox2_trigger_image_size', array('thumbnail' => t('Thumbnail')));
+ $trigger_image_sizes = '';
foreach ($trigger_sizes as $size => $size_name) {
$image_node_classes .= "img.$size, img.image-$size,";
+ $trigger_image_sizes .= ".$size|";
}
-
$image_node_classes = rtrim($image_node_classes, ",");
+ $trigger_image_sizes = '('. rtrim($trigger_image_sizes, "|") .')';
// Load the javascript settings.
$js_settings = array(
@@ -440,6 +442,7 @@ function lightbox2_add_files() {
'disable_zoom' => variable_get('lightbox2_disable_zoom', false),
'force_show_nav' => variable_get('lightbox2_force_show_nav', false),
'image_node_classes' => $image_node_classes,
+ 'trigger_image_sizes' => $trigger_image_sizes,
'group_images' => variable_get('lightbox2_image_group', true),
'disable_for_gallery_lists' => variable_get('lightbox2_disable_nested_galleries', true),
'disable_for_acidfree_gallery_lists' => variable_get('lightbox2_disable_nested_acidfree_galleries', true),