Skip to content

Commit

Permalink
loading svg previewers
Browse files Browse the repository at this point in the history
  • Loading branch information
BenediktMeierUIT committed Jun 3, 2024
1 parent 8ccccda commit 76b2cd5
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions previewers/betatest/js/retriever.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,8 @@ function addStandardPreviewHeader(file, title, authors) {

// Add logo from source Dataverse or use a local one, unless we are in preview mode
$('#logo')
.attr('src', queryParams.siteUrl + '/logos/preview_logo.png')
.attr(
'onerror',
'this.onerror=null;this.src="images/logo_placeholder.png";');
.attr('src', queryParams.siteUrl + '/logos/preview_logo.svg')
.attr('onerror', "handleImageError(this)");
}
//Footer
var footer = $.i18n("footer");
Expand Down Expand Up @@ -305,3 +303,17 @@ function reportFailure(msg, statusCode) {
+ errorText
+ statusCode);
}

function handleImageError(image) {
let currentFallback = parseInt(image.getAttribute('data-fallback-index') || '0');

if(currentFallback == 0){
image.src = queryParams.siteUrl + '/logos/preview_logo.png';
image.dataset.fallbackIndex = 1;
}
else{
image.src = 'images/logo_placeholder.png';
image.onerror = null;
}

}

0 comments on commit 76b2cd5

Please sign in to comment.