From fba298c26f4b3bfc6e0958be9e21af5e60e94608 Mon Sep 17 00:00:00 2001 From: rillke Date: Thu, 12 Feb 2015 00:45:20 +0100 Subject: [PATCH] Expose file size and MIME to Lua Use cases: - size: Showing links (like to SVG validator) conditionally (e.g. only if the filesize is below the threshold it can work on) - mime: No longer have to guess the MIME type based on the file extension. We use the MIME type for displaying correct and precise information about maximum thumbnailable sizes in case an uploaded work exceeds this limit. This change will not have negative impact on performance; as soon as width or height is loaded, the two newly added information are gratis. Change-Id: I25aad85c2a558a684aca83374aeb628f355fad1c --- engines/LuaCommon/TitleLibrary.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engines/LuaCommon/TitleLibrary.php b/engines/LuaCommon/TitleLibrary.php index 635683b4..d83dcc9c 100644 --- a/engines/LuaCommon/TitleLibrary.php +++ b/engines/LuaCommon/TitleLibrary.php @@ -309,6 +309,8 @@ class Scribunto_LuaTitleLibrary extends Scribunto_LuaLibraryBase { 'exists' => true, 'width' => $file->getWidth(), 'height' => $file->getHeight(), + 'mimeType' => $file->getMimeType(), + 'size' => $file->getSize(), 'pages' => $pages ) ); }