File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed
Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -49,10 +49,24 @@ async function make_gallery(id, images) {
4949 const description_element = '<div class="image-tab-gallery-description row"></div>' ;
5050 const current_image_element = '<div class="image-tab-gallery-current-image col-md-5"></div>' ;
5151
52- const tabs = images_with_metadata . map (
53- image => '<div class="image-tab-gallery-tab" title="' + image . alt + '" data-src="' + image . metadata . jpeg [ 0 ] . url + '">' +
54- '<img src="' + image . thumb_metadata . jpeg [ 1 ] . url + '" loading="lazy" decoding="async" width="128" height="112" alt="' + image . alt + '">' +
55- '</div>' ) ;
52+ const tabs = images_with_metadata . map ( image => {
53+ let thumbnailUrl = '' ;
54+ let mainImageUrl = '' ;
55+ const thumbnailAlt = image . alt || '' ;
56+ if ( image . thumb_metadata ?. jpeg ?. [ 1 ] ?. url ) {
57+ thumbnailUrl = image . thumb_metadata . jpeg [ 1 ] . url ;
58+ } else {
59+ console . warn ( `Tab Gallery: Missing thumbnail for image alt='${ thumbnailAlt } '. Falling back to empty src.` ) ;
60+ }
61+ if ( image . metadata ?. jpeg ?. [ 0 ] ?. url ) {
62+ mainImageUrl = image . metadata . jpeg [ 0 ] . url ;
63+ } else {
64+ console . warn ( `Tab Gallery: Missing main image for image alt='${ thumbnailAlt } '. Falling back to empty src.` ) ;
65+ }
66+ return '<div class="image-tab-gallery-tab" title="' + thumbnailAlt + '" data-src="' + mainImageUrl + '">' +
67+ '<img src="' + thumbnailUrl + '" loading="lazy" decoding="async" width="128" height="112" alt="' + thumbnailAlt + '">' +
68+ '</div>' ;
69+ } ) ;
5670 // put the joined tabs in the tabs element.
5771
5872 const tabs_element = '<div class="image-tab-gallery-tabs col-md-3">' + tabs . join ( "\n" ) + '</div>' ;
You can’t perform that action at this time.
0 commit comments