]> Lady’s Gitweb - Gitweb/commitdiff
gitweb: Avoid overflowing page body frame with large images
authorAndrew Keller <redacted>
Mon, 17 Feb 2014 14:25:13 +0000 (09:25 -0500)
committerLady <redacted>
Mon, 6 Apr 2026 04:51:32 +0000 (00:51 -0400)
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 <redacted>
Signed-off-by: Junio C Hamano <redacted>
gitweb.perl
static/gitweb.css

index 1c8196ba2c52445f0dbdf93dd4efad2aee73e5bc8f411408bc4eed60ecacf492..39f6641460280c3d7052710aa467efa4102082c4cd8d795c1871b1019b370d31 100755 (executable)
@@ -7095,7 +7095,7 @@ sub git_blob {
        git_print_page_path($file_name, "blob", $hash_base);
        print "<div class=\"page_body\">\n";
        if ($mimetype =~ m!^image/!) {
-               print qq!<img type="!.esc_attr($mimetype).qq!"!;
+               print qq!<img class="blob" type="!.esc_attr($mimetype).qq!"!;
                if ($file_name) {
                        print qq! alt="!.esc_attr($file_name).qq!" title="!.esc_attr($file_name).qq!"!;
                }
index 46449f1e7cb54f1b7b657abff80ba731fa1d2ed0e3919162ba0399885074dbea..15792fe9cad49d18cc5ed5a2b4854611183a1109272a90cf3a4936b0ab63dc03 100644 (file)
@@ -32,6 +32,11 @@ img.avatar {
        vertical-align: middle;
 }
 
+img.blob {
+       max-height: 100%;
+       max-width: 100%;
+}
+
 a.list img.avatar {
        border-style: none;
 }
This page took 0.306514 seconds and 4 git commands to generate.