Fix post resize image control

It was resizing images to the original width and height, even if
they were currently being shown in their large image format (850px).
This was causing excessive blur and artifacts in some cases.
This commit is contained in:
BrokenEagle
2020-02-14 20:46:57 +00:00
parent 115355ab7b
commit 2affd4a3b5

View File

@@ -361,6 +361,9 @@ Post.resize_image_to_window = function($img) {
var sidebar_width = 0;
var client_width = 0;
var isVideo = $img.prop("tagName") === "VIDEO";
var width = isVideo ? $img.prop("width") : $img.prop('naturalWidth');
var height = isVideo ? $img.prop("height") : $img.prop('naturalHeight');
if (($img.data("scale-factor") === 1) || ($img.data("scale-factor") === undefined)) {
if ($(window).width() > 660) {
sidebar_width = $("#sidebar").width() || 0;
@@ -370,9 +373,6 @@ Post.resize_image_to_window = function($img) {
}
if ($img.width() > client_width) {
var isVideo = $img.prop("tagName") === "VIDEO";
var width = isVideo ? $img.prop("width") : $img.data("original-width");
var height = isVideo ? $img.prop("height") : $img.data("original-height");
var ratio = client_width / width;
$img.data("scale-factor", ratio);
$img.css("width", width * ratio);
@@ -381,8 +381,8 @@ Post.resize_image_to_window = function($img) {
}
} else {
$img.data("scale-factor", 1);
$img.width($img.data("original-width"));
$img.height($img.data("original-height"));
$img.width(width);
$img.height(height);
Post.resize_ugoira_controls();
}