From dfcf18917b925f0d2a188f510c62a793bb7aa36f Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Fri, 13 Feb 2015 07:15:55 +0000 Subject: [PATCH] improved the code_file view slightly to display a image stream as an image --- codepot/src/codepot/views/code_file.php | 37 ++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/codepot/src/codepot/views/code_file.php b/codepot/src/codepot/views/code_file.php index 90cbea21..5590687c 100644 --- a/codepot/src/codepot/views/code_file.php +++ b/codepot/src/codepot/views/code_file.php @@ -230,7 +230,42 @@ if ($login['settings'] != NULL && ?>
-
+ 0)
+	{
+		foreach ($file['properties'] as $pn => $pv)
+		{
+			if ($pn == 'svn:mime-type' && $pv == 'application/octet-stream')
+			{
+				$is_octet_stream = 1;
+				break;
+			}
+			else if ($pn == 'svn:executable' && $pv == '*')
+			{
+				if (in_array (strtolower($fileext), array ('png', 'jpg', 'gif', 'tif', 'bmp', 'ico')))
+				{
+					$is_octet_stream = -1; /* not sure */
+					break;
+				}
+			}
+		}
+	}
+
+	$is_image_stream = FALSE;
+	if ($is_octet_stream != 0)
+	{
+		$img = @imagecreatefromstring ($file['content']);		
+		if ($img !== FALSE)
+		{
+			@imagedestroy ($img);
+			print ('[image]');
+			$is_image_stream = TRUE;
+		}
+	}
+
+	if (!$is_image_stream) print htmlspecialchars($file['content']); 
+?>