Add video support to resize_image_to_window

This should make videos automatically scale on the mobile view.
This commit is contained in:
Nicolas Stepien
2019-07-25 23:20:14 +01:00
committed by GitHub
parent 716076437e
commit 2d25519e18

View File

@@ -370,10 +370,13 @@ Post.resize_image_to_window = function($img) {
}
if ($img.width() > client_width) {
var ratio = client_width / $img.data("original-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", $img.data("original-width") * ratio);
$img.css("height", $img.data("original-height") * ratio);
$img.css("width", width * ratio);
$img.css("height", height * ratio);
Post.resize_ugoira_controls();
}
} else {