Skip to content

Commit 6f4ff4e

Browse files
committed
Update finna.js
Work on license, images, formats
1 parent 2b558d0 commit 6f4ff4e

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

finna.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,6 @@ module.exports = {
117117
if (collectionElements.length > 2) collection = collectionElements[2];
118118
}
119119

120-
let formats = "";
121-
if ((record.formats!=undefined) && (record.formats.length>1) && (record.formats[1].value!=undefined)) {
122-
let formatsElements = record.formats[1].value.split("/");
123-
if (formatsElements.length > 2) formats = formatsElements[2];
124-
}
125-
126120
// let thumbURL = BASE_URL + record.images[0];
127121
let thumbURL = '/static/pngs/imageplaceholder.png';
128122
if (!!record.imagesExtended) {
@@ -152,15 +146,16 @@ module.exports = {
152146
description: record.summary,
153147
details: record.subjectDetails,
154148
downloadURL: '',
155-
formats: formats,
149+
formats: [],
156150
geoLocations: (record.geoLocations != undefined ? record.geoLocations : []),
157151
id: record.id,
158-
imageURL: BASE_URL + record.images[0],
152+
imageURL: '',
159153
infoURL: "https://www.finna.fi/Record/" + encodeURIComponent(record.id),
160154
inscriptions: record.inscriptions,
161155
institutions: [],
162156
inventoryNumber: record.identifierString,
163-
license: (record.imageRights != undefined ? record.imageRights.copyright : ""),
157+
license: '',
158+
license_link: '',
164159
materials: materials,
165160
measurements: record.measurements,
166161
places: record.subjectPlaces,
@@ -177,6 +172,20 @@ module.exports = {
177172
image.title.push(record.title);
178173
}
179174

175+
if ((record.formats != undefined) && (record.formats.length > 1)) {
176+
image.formats = record.formats[record.formats.length - 1].translated;
177+
}
178+
179+
if (record.imagesExtended) {
180+
let displayImage = record.imagesExtended[record.imagesExtended.length - 1].urls.large ? record.imagesExtended[record.imagesExtended.length - 1].urls.large : record.imagesExtended[record.imagesExtended.length - 1].urls.medium;
181+
image.imageURL = BASE_URL + displayImage;
182+
}
183+
184+
if (record.imageRights != undefined) {
185+
image.license_link = record.imageRights.link;
186+
image.license = record.imageRights.copyright;
187+
}
188+
180189
if (record.institutions) {
181190
for (let institution of record.institutions) {
182191
image.institutions.push(institution.translated);

0 commit comments

Comments
 (0)