Skip to content

Commit

Permalink
Added support for retina images using srcset in img tag.
Browse files Browse the repository at this point in the history
- Used by adding srcset string when pushing images to gallery.
  • Loading branch information
hennikul committed Jan 30, 2015
1 parent 0684fe4 commit c96cea8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/galleria.js
Original file line number Diff line number Diff line change
Expand Up @@ -4905,6 +4905,12 @@ 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 );
$( image.image ).attr( 'sizes', image.width+"px" );
}

self.trigger($.extend(evObj, {
type: Galleria.LOADFINISH
}));
Expand Down Expand Up @@ -5151,6 +5157,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 );
Expand Down

0 comments on commit c96cea8

Please sign in to comment.