diff client/digitallibrary/jquery/jquery.digilib.js @ 863:ca2c022a9baa jquery

keep title and alt attributes from HTML for scaler img
author hertzhaft
date Sat, 12 Mar 2011 21:58:06 +0100
parents a135f590275d
children e5caceb1832b
line wrap: on
line diff
--- a/client/digitallibrary/jquery/jquery.digilib.js	Sat Mar 12 21:22:15 2011 +0100
+++ b/client/digitallibrary/jquery/jquery.digilib.js	Sat Mar 12 21:58:06 2011 +0100
@@ -980,14 +980,17 @@
             scalerUrl = getScalerUrl(data);
             $img = $elem.find('img');
             if ($img.length > 0) {
-                //oldUrl = $img.attr('src');
-                //if (oldUrl === scalerUrl) {
-                //    console.debug("img detach:", $img);
-                //    $img.detach();
-                //} else {
-                //    $img = $('<img/>');
-                // keep title, alt etc. attributes (src gets changed anyway) 
-                $img.detach();
+                var oldUrl = $img.attr('src');
+                // keep img attributes from html
+                var title = $img.attr('title');
+                var alt = $img.attr('alt');
+                if (oldUrl === scalerUrl) {
+                    console.debug("img detach:", $img);
+                    $img.detach();
+                } else {
+                    $img = $('<img/>');
+                    $img.attr("title", title);
+                    $img.attr("alt", alt);
                 }
             } else {
                 $img = $('<img/>');