summaryrefslogtreecommitdiffstats
path: root/application/service/files.php
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2016-09-02 00:46:18 +0200
committerFlorian Pritz <bluewind@xinu.at>2016-09-19 21:41:30 +0200
commita703f4987c69670f0d4007624d3dd61ef27bccb0 (patch)
tree5ab9452c158fcde74c74b73ac6d7a17241e8922f /application/service/files.php
parentc199a758635f04c193b812052186fe19366f4f2e (diff)
Extract tooltip function into \service\files
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/service/files.php')
-rw-r--r--application/service/files.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/application/service/files.php b/application/service/files.php
index 54b1f85af..746cd1162 100644
--- a/application/service/files.php
+++ b/application/service/files.php
@@ -411,4 +411,32 @@ class files {
return true;
}
+
+ static public function tooltip(array $filedata)
+ {
+ $filesize = format_bytes($filedata["filesize"]);
+ $file = get_instance()->mfile->file($filedata["data_id"]);
+ $upload_date = date("r", $filedata["date"]);
+
+ $height = 0;
+ $width = 0;
+ try {
+ list($width, $height) = getimagesize($file);
+ } catch (\ErrorException $e) {
+ // likely unsupported filetype
+ }
+
+ $tooltip = "${filedata["id"]} - $filesize<br>";
+ $tooltip .= "$upload_date<br>";
+
+
+ if ($height > 0 && $width > 0) {
+ $tooltip .= "${width}x${height} - ${filedata["mimetype"]}<br>";
+ } else {
+ $tooltip .= "${filedata["mimetype"]}<br>";
+ }
+
+ return $tooltip;
+ }
+
}