diff --git a/src/galleria.js b/src/galleria.js index a29a51c1..dd35d84a 100644 --- a/src/galleria.js +++ b/src/galleria.js @@ -4905,6 +4905,17 @@ this.prependChild( 'info', 'myElement' ); self._layers[index].innerHTML = self.getData().layer || ''; + // Set srcset in img tag for responsive retina images. + if (data.srcset) { + $( image.image ).attr( 'srcset', data.srcset ); + if (image.width) { + $( image.image ).attr( 'sizes', image.width+"px" ); + } else { + // We don't know the size of the image yet, but it can't be wider than the viewport + $( image.image ).attr( 'sizes', "100wv" ); + } + } + self.trigger($.extend(evObj, { type: Galleria.LOADFINISH })); @@ -5151,6 +5162,12 @@ this.prependChild( 'info', 'myElement' ); complete: function( next ) { + // Set srcset in img tag for responsive retina images. + if (data.srcset) { + $( next.image ).attr( 'srcset', data.srcset ); + $( next.image ).attr( 'sizes', next.width+"px" ); + } + // toggle low quality for IE if ( 'image' in active ) { Utils.toggleQuality( active.image, false );