@@ -32,7 +32,7 @@ document.addEventListener('DOMContentLoaded', function() {
3232 }
3333 } ) ;
3434
35- // Initialize Magnific Popup on all gallery images (do this once after processing all sections)
35+ // Initialize Magnific Popup on manually created gallery images
3636 if ( document . querySelectorAll ( '.gallery-image' ) . length > 0 ) {
3737 jQuery ( '.gallery-image' ) . magnificPopup ( {
3838 type : 'image' ,
@@ -46,4 +46,50 @@ document.addEventListener('DOMContentLoaded', function() {
4646 }
4747 } ) ;
4848 }
49+
50+ // Initialize Magnific Popup for photos plugin galleries
51+ // These are already created by the pelican photos plugin
52+ if ( document . querySelectorAll ( '.gallery-item' ) . length > 0 ) {
53+ jQuery ( '.gallery-item' ) . magnificPopup ( {
54+ type : 'image' ,
55+ gallery : {
56+ enabled : true ,
57+ navigateByImgClick : true ,
58+ preload : [ 0 , 1 ]
59+ } ,
60+ image : {
61+ titleSrc : function ( item ) {
62+ // Use data-caption if available, otherwise use title attribute
63+ const caption = item . el . attr ( 'data-caption' ) ;
64+ const exif = item . el . attr ( 'data-exif' ) ;
65+ let title = caption || item . el . attr ( 'title' ) || '' ;
66+
67+ // Add EXIF data as an expandable details section if available
68+ if ( exif && exif !== 'None' ) {
69+ title += '<details class="mfp-exif-details"><summary>Photo details</summary><small>' + exif + '</small></details>' ;
70+ }
71+
72+ return title ;
73+ } ,
74+ markup : '<div class="mfp-figure">' +
75+ '<div class="mfp-close"></div>' +
76+ '<div class="mfp-img"></div>' +
77+ '<div class="mfp-bottom-bar">' +
78+ '<div class="mfp-title"></div>' +
79+ '<div class="mfp-counter"></div>' +
80+ '</div>' +
81+ '</div>'
82+ } ,
83+ callbacks : {
84+ markupParse : function ( template , values , item ) {
85+ // Manually set the title HTML to avoid escaping
86+ if ( values . title ) {
87+ setTimeout ( ( ) => {
88+ template . find ( '.mfp-title' ) . html ( values . title ) ;
89+ } , 0 ) ;
90+ }
91+ }
92+ }
93+ } ) ;
94+ }
4995} ) ;
0 commit comments