Skip to content

Commit

Permalink
Disable EXIF orientation CSS fix for browsers which natively support …
Browse files Browse the repository at this point in the history
…the transformation

Chrome 81 (released on April 7th) added native support for rotating images based on EXIF. Disable CSS fix so the image display correctly on newer Chrome versions with the fix.

References:
* https://www.chromestatus.com/feature/6313474512650240
* http://crbug.com/158753
* https://paul.kinlan.me/correct-image-orientation-for-images-chrome-81/
* https://www.chromestatus.com/features/schedule
  • Loading branch information
playmobil42 committed Apr 24, 2020
1 parent 58f53f7 commit 47b86aa
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions MMM-BackgroundSlideshow.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ Module.register('MMM-BackgroundSlideshow', {
if (this.config.backgroundAnimationDuration === '1s') {
this.config.backgroundAnimationDuration = (this.config.slideshowSpeed/1000) + 's';
}

// Chrome versions < 81 do not support EXIF orientation natively. A CSS transformation
// needs to be applied for the image to display correctly - see http://crbug.com/158753 .
this.browserSupportsExifOrientationNatively = CSS.supports('image-orientation: from-image');
},

getScripts: function() {
Expand Down Expand Up @@ -335,8 +339,11 @@ Module.register('MMM-BackgroundSlideshow', {
this.updateImageInfo(decodeURI(image.src), dateTime);

}
const exifOrientation = EXIF.getTag(image, "Orientation");
this.div1.style.transform = this.getImageTransformCss(exifOrientation);

if (!this.browserSupportsExifOrientationNatively) {
const exifOrientation = EXIF.getTag(image, "Orientation");
this.div1.style.transform = this.getImageTransformCss(exifOrientation);
}
});
this.div2.style.opacity = '0';
};
Expand Down

0 comments on commit 47b86aa

Please sign in to comment.