Digital images in the catalog user/kmlussier/digital-images-in-the-catalog
authorKathy Lussier <klussier@masslnc.org>
Wed, 2 Nov 2016 15:16:14 +0000 (11:16 -0400)
committerKathy Lussier <klussier@masslnc.org>
Wed, 2 Nov 2016 15:16:14 +0000 (11:16 -0400)
Custom code done by Equinox and running on the NOBLE server. Takes images from
the 956 field and displays them in the record summary page of the catalog.

Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/templates/opac/css/style.css.tt2
Open-ILS/src/templates/opac/parts/record/summary.tt2

index 8a3c4f7..f86b8eb 100644 (file)
@@ -2148,3 +2148,31 @@ label[for*=expert_]
   color: [% css_colors.text_badnews %]; 
   padding: 10px;
 }
+
+.custom_thumbnail_container {
+    margin: 20px auto;
+    text-align: center;
+    width: 90%;
+    min-height: 200px;
+    overflow: auto;
+    display: inline-block;
+}
+
+a.custom_thumbnail {
+    margin: 0px 20px;
+    text-align: center;
+    display: inline-block;
+    text-decoration: none;
+    color: black;
+}
+
+img.custom_thumbnail {
+    max-height: 150px;
+    max-width: 150px;
+}
+
+.custom_thumbnail_caption {
+    text-align: center;
+    color: black;
+    font-weight: bold;
+}
index b2bd5e5..c4a4360 100644 (file)
 [%- END %]
 [%- END %]
 [%- merged_uris = args.uris.merge(args.online_res);
+file_ext_re = '\.(?i:jpe?g|png|bmp|gif|tif|psd|thm|yuv)$';
+
+thumbnails = [];
+
+FOR uri_field IN attrs.marc_xml.findnodes('//*[@tag="956"]');
+    tn = {};
+
+    x = uri_field.findnodes('./*[@code="t"]/text()');
+    FOR i IN x;
+        tn.thumb = i.textContent;
+    END;
+
+    x = uri_field.findnodes('./*[@code="u"]/text()');
+    FOR i IN x;
+        tn.target = i.textContent;
+    END;
+
+    x = uri_field.findnodes('./*[@code="c"]/text()');
+    FOR i IN x;
+        tn.caption = i.textContent;
+    END;
+
+    IF tn.target.length > 0;
+        IF !tn.caption;
+            tn.caption = '';
+        END;
+        IF !tn.thumb AND tn.target.match(file_ext_re);
+            tn.thumb = tn.target;
+        END;
+        thumbnails.push(tn);
+    END;
+END;
+
+-%]
+
+<div class="custom_thumbnail_container">
+    [%- FOR tn IN thumbnails %]
+        <a class="custom_thumbnail"
+           href="[% tn.target %]">
+                <img class="custom_thumbnail" src="[% tn.thumb %]" alt="[% tn.caption | html %]"/>
+                <div class="custom_thumbnail_caption">[% tn.caption %]</div>
+        </a>
+    [%- END %]
+</div>
 num_uris = merged_uris.size;
 IF num_uris > 0;
 -%]