diff --git a/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css b/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css index cf8a254a92c..1a3c75da7de 100644 --- a/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css +++ b/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css @@ -3408,7 +3408,6 @@ Column content } .ui-tooltip.mediaListImageTooltip > .ui-tooltip-text > img { - max-width: 30vw; max-height: 40vh; } diff --git a/Kitodo/src/main/webapp/WEB-INF/resources/js/metadata_editor.js b/Kitodo/src/main/webapp/WEB-INF/resources/js/metadata_editor.js index e0922870cd9..20f27bc0476 100644 --- a/Kitodo/src/main/webapp/WEB-INF/resources/js/metadata_editor.js +++ b/Kitodo/src/main/webapp/WEB-INF/resources/js/metadata_editor.js @@ -394,6 +394,29 @@ metadataEditor.gallery = { this.updateDiscontinuousSecletionState(); }, + /** + * Preload the images in tooltip. + * + * To improve performance, the images within the tooltips are loaded only when the tooltip is displayed. + * For the preview image, it makes no difference, as the image is already loaded. However, if the image + * from the MediaView is to be displayed in the tooltip, it must be preloaded. Otherwise, the tooltip appears + * at a shifted position because, at the time of display, it does not yet know the size of its content. + */ + preloadTooltipImage(tooltip) { + let tooltipElement = document.getElementById(tooltip.id); + if (!tooltipElement.hasAttribute("data-preloaded")) { + let tempImage = new Image(); + tempImage.src = tooltipElement.getElementsByTagName('img')[0].src; + tempImage.onload = function () { + tooltipElement.setAttribute("data-preloaded", "true"); + tooltipElement.getElementsByTagName('img')[0].height = tempImage.height; + PF(tooltip.cfg.widgetVar).show(); + } + return false; + } + return true; + }, + /** * Checks whether selection is a continuous selection and applies corresponding CSS style class. */ diff --git a/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/partials/media-list-overlay.xhtml b/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/partials/media-list-overlay.xhtml index 586d136d248..a048b94559a 100644 --- a/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/partials/media-list-overlay.xhtml +++ b/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/partials/media-list-overlay.xhtml @@ -15,7 +15,8 @@ xmlns:p="http://primefaces.org/ui" xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:h="http://xmlns.jcp.org/jsf/html" - xmlns:ui="http://xmlns.jcp.org/jsf/facelets"> + xmlns:ui="http://xmlns.jcp.org/jsf/facelets" + xmlns:a="http://xmlns.jcp.org/jsf/passthrough"> + + value="#{mediaProvider.mediaView}" + a:loading="lazy"> + value="#{mediaProvider.previewData}" + a:loading="lazy">