@@ -80,8 +80,8 @@ function formatNumber(n, digits = 1) {
8080 return String ( parseFloat ( fixed ) ) ;
8181}
8282
83- function renderExifRows ( exif ) {
84- const rows = [
83+ function getExifRows ( exif ) {
84+ return [
8585 { label : 'Camera' , value : formatCamera ( exif ) } ,
8686 { label : 'Lens' , value : exif ?. LensModel ?. trim ( ) } ,
8787 { label : 'Date' , value : formatDate ( exif ?. DateTimeOriginal ) } ,
@@ -90,17 +90,23 @@ function renderExifRows(exif) {
9090 { label : 'Shutter' , value : formatExposureTime ( exif ?. ExposureTime ) } ,
9191 { label : 'ISO' , value : exif ?. ISO != null ? String ( Number ( exif . ISO ) ) : '' }
9292 ] . filter ( r => r . value ) ;
93+ }
9394
95+ function renderExifRows ( exif ) {
96+ const rows = getExifRows ( exif ) ;
9497 if ( rows . length === 0 ) return '<div class="dg-exif-empty">No EXIF data available</div>' ;
9598
9699 return rows
97100 . map ( r => `<div class="dg-exif-row"><span class="dg-exif-label">${ r . label } </span><span class="dg-exif-value">${ r . value } </span></div>` )
98101 . join ( '' ) ;
99102}
100103
101- async function loadExifPanel ( rawSrc , overlay ) {
104+ async function loadExifPanel ( rawSrc , overlay , seededExif = null ) {
102105 try {
103- const exif = await exifr . parse ( rawSrc , { gps : false , icc : false , xmp : false } ) ;
106+ let exif = seededExif ;
107+ if ( ! getExifRows ( exif ) . length ) {
108+ exif = await exifr . parse ( rawSrc , { gps : false , icc : false , xmp : false } ) ;
109+ }
104110 if ( ! exif ) return ;
105111 const panel = document . createElement ( 'div' ) ;
106112 panel . className = 'dg-exif-panel' ;
@@ -143,7 +149,8 @@ function buildItems(pool, seg) {
143149 alt : image . alt || '' ,
144150 width : image . width ,
145151 height : image . height ,
146- sizes : image . sizes
152+ sizes : image . sizes ,
153+ exif : image . exif || null
147154 } ;
148155 } ) ;
149156
@@ -168,7 +175,8 @@ function buildItems(pool, seg) {
168175 alt : usedImages [ i ] . alt ,
169176 width : usedImages [ i ] . width ,
170177 height : usedImages [ i ] . height ,
171- sizes : usedImages [ i ] . sizes
178+ sizes : usedImages [ i ] . sizes ,
179+ exif : usedImages [ i ] . exif
172180 } ) ) ;
173181}
174182
@@ -577,6 +585,14 @@ export default function DomeGallery({
577585 overlay . style . transformOrigin = 'top left' ;
578586 overlay . style . transition = `transform ${ enlargeTransitionMs } ms ease, opacity ${ enlargeTransitionMs } ms ease` ;
579587 const rawSrc = parent . dataset . src || el . querySelector ( 'img' ) ?. src || '' ;
588+ let seededExif = null ;
589+ if ( parent . dataset . exif ) {
590+ try {
591+ seededExif = JSON . parse ( parent . dataset . exif ) ;
592+ } catch {
593+ seededExif = null ;
594+ }
595+ }
580596 const imgWrap = document . createElement ( 'div' ) ;
581597 imgWrap . className = 'enlarge__image-wrap' ;
582598 const img = document . createElement ( 'img' ) ;
@@ -645,7 +661,7 @@ export default function DomeGallery({
645661 overlay . removeEventListener ( 'transitionend' , cleanupSecond ) ;
646662 overlay . style . transition = prevTransition ;
647663 overlay . classList . add ( 'enlarge--ready' ) ;
648- loadExifPanel ( rawSrc , overlay ) ;
664+ loadExifPanel ( rawSrc , overlay , seededExif ) ;
649665 } ;
650666 overlay . addEventListener ( 'transitionend' , cleanupSecond , { once : true } ) ;
651667 } ;
@@ -710,6 +726,7 @@ export default function DomeGallery({
710726 key = { `${ it . x } ,${ it . y } ,${ i } ` }
711727 className = "item"
712728 data-src = { it . src }
729+ data-exif = { it . exif ? JSON . stringify ( it . exif ) : undefined }
713730 data-offset-x = { it . x }
714731 data-offset-y = { it . y }
715732 data-size-x = { it . sizeX }
0 commit comments