Browse Source

! Don't save the size of an attachment if it isn't quite an image.

Signed-off-by: Peter Spicer <sleeping@myperch.org>
Peter Spicer 11 years ago
parent
commit
deefb3e112
1 changed files with 8 additions and 0 deletions
  1. 8 0
      Sources/Subs-Attachments.php

+ 8 - 0
Sources/Subs-Attachments.php

@@ -706,6 +706,14 @@ function createAttachment(&$attachmentOptions)
 			$attachmentOptions['mime_type'] = 'image/' . $validImageTypes[$size[2]];
 	}
 
+	// It is possible we might have a MIME type that isn't actually an image but still have a size.
+	// For example, Shockwave files will be able to return size but be 'application/shockwave' or similar.
+	if (!empty($attachmentOptions['mime_type']) && strpos($attachmentOptions['mime_time'], 'image/') !== 0)
+	{
+		$attachmentOptions['width'] = 0;
+		$attachmentOptions['height'] = 0;
+	}
+
 	// Get the hash if no hash has been given yet.
 	if (empty($attachmentOptions['file_hash']))
 		$attachmentOptions['file_hash'] = getAttachmentFilename($attachmentOptions['name'], false, null, true);