Add video support to resize_image_to_window
This should make videos automatically scale on the mobile view.
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user