Mercurial > hg > digilib-old
changeset 870:80cc227c1d50 jquery
keep title and alt attributes from HTML for scaler img
author | hertzhaft |
---|---|
date | Sat, 12 Mar 2011 21:58:06 +0100 |
parents | 44ee29f20791 |
children | e17507559d35 |
files | client/digitallibrary/jquery/jquery-test-embedded.html client/digitallibrary/jquery/jquery.digilib.js |
diffstat | 2 files changed, 12 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/client/digitallibrary/jquery/jquery-test-embedded.html Sat Mar 12 21:22:15 2011 +0100 +++ b/client/digitallibrary/jquery/jquery-test-embedded.html Sat Mar 12 21:58:06 2011 +0100 @@ -85,7 +85,7 @@ <tr> <td> <div id="digilib-1" class="digilib single"> - <img src="http://digilib.biblhertz.it/digilib04/servlet/Scaler?dw=200&dh=200&fn=/digisprint/jquery/&pn=1" /> + <img title="test" alt="testalt" src="http://digilib.biblhertz.it/digilib04/servlet/Scaler?dw=200&dh=200&fn=/digisprint/jquery/&pn=1" /> </div> </td>
--- 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/>');