Skip to content

Commit 46a7471

Browse files
andrewkellergitster
authored andcommitted
gitweb: Avoid overflowing page body frame with large images
When displaying a blob in gitweb, if it's an image, specify constraints for maximum display width and height to prevent the image from overflowing the frame of the enclosing page_body div. This change assumes that it is more desirable to see the whole image without scrolling (new behavior) than it is to see every pixel without zooming (previous behavior). Signed-off-by: Andrew Keller <andrew@kellerfarm.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 5f95c9f commit 46a7471

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

gitweb/gitweb.perl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7094,7 +7094,7 @@ sub git_blob {
70947094
git_print_page_path($file_name, "blob", $hash_base);
70957095
print "<div class=\"page_body\">\n";
70967096
if ($mimetype =~ m!^image/!) {
7097-
print qq!<img type="!.esc_attr($mimetype).qq!"!;
7097+
print qq!<img class="blob" type="!.esc_attr($mimetype).qq!"!;
70987098
if ($file_name) {
70997099
print qq! alt="!.esc_attr($file_name).qq!" title="!.esc_attr($file_name).qq!"!;
71007100
}

gitweb/static/gitweb.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ img.avatar {
3232
vertical-align: middle;
3333
}
3434

35+
img.blob {
36+
max-height: 100%;
37+
max-width: 100%;
38+
}
39+
3540
a.list img.avatar {
3641
border-style: none;
3742
}

0 commit comments

Comments
 (0)