Skip to content

Commit

Permalink
Merge pull request #2400 from guardian/mk-preview-image-FF-fix
Browse files Browse the repository at this point in the history
Request correctly sized imgops preview image in Firefox
  • Loading branch information
paperboyo committed Jan 31, 2019
2 parents 62d52a9 + 64ca374 commit 0b55620
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions kahuna/public/js/imgops/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@ imgops.factory('imgops', ['$window', function($window) {

const lowResMaxWidth = 800;
const lowResMaxHeight = 800;

const isFF = !!$window.navigator.userAgent.match(/firefox/i);

function getFullScreenUri(image) {
const { width: w, height: h } = $window.screen;
let { width: w, height: h } = $window.screen;
if (isFF) {
const zoom = $window.devicePixelRatio;
if (zoom !== 1) {
h = Math.round(h * zoom);
w = Math.round(w * zoom);
}
}

return getOptimisedUri(image, { w, h, q: quality });
}

Expand Down

0 comments on commit 0b55620

Please sign in to comment.