Browse Source

Apply image preview centering styles only if there's an image

For cases when we display a security warning about the image attachment
the image centering styles would make the warning centered, which
we do not want.
pull/6908/head
Aleksander Machniak 6 years ago
parent
commit
b35c9c1fdc
  1. 15
      program/js/app.js

15
program/js/app.js

@ -425,12 +425,19 @@ function rcube_webmail()
}
// center and scale the image in preview frame
// TODO: Find a better way. Onload is late, also we could use embed.css
if (this.env.mimetype.startsWith('image/'))
$(this.gui_objects.messagepartframe).on('load', function() {
var css = 'img { max-width:100%; max-height:100%; } ' // scale
+ 'body { display:flex; align-items:center; justify-content:center; height:100%; margin:0; }'; // align
$(this).contents().find('head').append('<style type="text/css">'+ css + '</style>');
var contents = $(this).contents();
// do not apply styles to an error page (with no image)
if (contents.find('img').length)
contents.find('head').append(
'<style type="text/css">'
+ 'img { max-width:100%; max-height:100%; } ' // scale
+ 'body { display:flex; align-items:center; justify-content:center; height:100%; margin:0; }' // align
+ '</style>'
);
});
}
// show printing dialog

Loading…
Cancel
Save