git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] gitweb: Avoid overflowing page body frame with large images

From
Andrew Keller <andrew@kellerfarm.com>
Date
Feb 17, 2014, 14:25 UTC
Message-ID
<C66B1A3C-7148-4514-B385-537E0BB6E187@kellerfarm.com>
In-Reply-To
<A4E05D52-1CED-46FC-B137-BCDFAD638E1D@kellerfarm.com>

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>
---
This is an updated copy of this patch.
Could I request a thumbs up, thumbs down, or thumbs sideways from those who develop gitweb?

Thanks, Andrew Keller

 gitweb/gitweb.perl       |    2 +-
 gitweb/static/gitweb.css |    5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 3bc0f0b..79057b7 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -7094,7 +7094,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!"!;
 		}
diff --git a/gitweb/static/gitweb.css b/gitweb/static/gitweb.css
index 3b4d833..3212601 100644
--- a/gitweb/static/gitweb.css
+++ b/gitweb/static/gitweb.css
@@ -32,6 +32,11 @@ img.avatar {
 	vertical-align: middle;
 }
 
+img.blob {
+	max-height: 100%;
+	max-width: 100%;
+}
+
 a.list img.avatar {
 	border-style: none;
 }
-- 
1.7.9.6 (Apple Git-31.1)
Previous: Andrew KellerNext: Junio C Hamano
Message 3 of 7 in “gitweb: Avoid overflowing page body frame with large images”
  1. gitweb: Avoid overflowing page body frame with large imagesAndrew Keller, Feb 7, 2014
  2. Andrew KellerFeb 7, 2014
  3. gitweb: Avoid overflowing page body frame with large imagesAndrew Keller, Feb 17, 2014
  4. Junio C HamanoFeb 19, 2014
  5. Vincent van RavesteijnFeb 7, 2014
  6. Andrew KellerFeb 7, 2014
  7. Tony FinchFeb 7, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.