diff options
Diffstat (limited to 'app/Helper/FileHelper.php')
-rw-r--r-- | app/Helper/FileHelper.php | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/app/Helper/FileHelper.php b/app/Helper/FileHelper.php index cabf371c..06589124 100644 --- a/app/Helper/FileHelper.php +++ b/app/Helper/FileHelper.php @@ -21,9 +21,7 @@ class FileHelper extends Base */ public function icon($filename) { - $extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); - - switch ($extension) { + switch (get_file_extension($filename)) { case 'jpeg': case 'jpg': case 'png': @@ -70,9 +68,7 @@ class FileHelper extends Base */ public function getImageMimeType($filename) { - $extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); - - switch ($extension) { + switch (get_file_extension($filename)) { case 'jpeg': case 'jpg': return 'image/jpeg'; @@ -94,9 +90,7 @@ class FileHelper extends Base */ public function getPreviewType($filename) { - $extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); - - switch ($extension) { + switch (get_file_extension($filename)) { case 'md': case 'markdown': return 'markdown'; @@ -106,4 +100,21 @@ class FileHelper extends Base return null; } + + /** + * Return the browser view mime-type based on the file extension. + * + * @access public + * @param $filename + * @return string + */ + public function getBrowserViewType($filename) + { + switch (get_file_extension($filename)) { + case 'pdf': + return 'application/pdf'; + } + + return null; + } } |