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>
Andrew Keller committed
Feb 17, 2014 at 09:25 UTC
46a7471f0e20af9d2efcc4a14c76d537e1551ac9
2 files changed
+6
-1
gitweb/gitweb.perl
+1
-1
@@ -7094,7 +7094,7 @@ sub git_blob {
7094
git_print_page_path($file_name, "blob", $hash_base);
7095
print "<div class=\"page_body\">\n";
7096
if ($mimetype =~ m!^image/!) {
7097
- print qq!<img type="!.esc_attr($mimetype).qq!"!;
7097
+ print qq!<img class="blob" type="!.esc_attr($mimetype).qq!"!;
7098
if ($file_name) {
7099
print qq! alt="!.esc_attr($file_name).qq!" title="!.esc_attr($file_name).qq!"!;
7100
}
gitweb/static/gitweb.css
+5
@@ -32,6 +32,11 @@ img.avatar {
32
vertical-align: middle;
33
}
34
35
+img.blob {
36
+ max-height: 100%;
37
+ max-width: 100%;
38
+}
39
+
40
a.list img.avatar {
41
border-style: none;
42
}