diff options
author | Corey Hulen <corey@hulen.com> | 2016-01-06 14:47:25 -0600 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2016-01-06 14:47:25 -0600 |
commit | fe7d27ba4b04537e39357227bcc55f8b92ee6ee2 (patch) | |
tree | 53fec096f1e388538553067e545d01189c8edaf2 /web/react/utils | |
parent | 0eb145218edb37d911cc5ec135b0006f866a44b2 (diff) | |
parent | a6ba1a17fe22a72d7058621cb29e9f60d9de0a08 (diff) | |
download | chat-fe7d27ba4b04537e39357227bcc55f8b92ee6ee2.tar.gz chat-fe7d27ba4b04537e39357227bcc55f8b92ee6ee2.tar.bz2 chat-fe7d27ba4b04537e39357227bcc55f8b92ee6ee2.zip |
Merge pull request #1815 from hmhealey/plt771
PLT-771 Improved Audio/Video preview for unsupported formats
Diffstat (limited to 'web/react/utils')
-rw-r--r-- | web/react/utils/utils.jsx | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx index a808c9be3..e84fdf671 100644 --- a/web/react/utils/utils.jsx +++ b/web/react/utils/utils.jsx @@ -527,6 +527,19 @@ export function splitFileLocation(fileLocation) { return {ext: ext, name: filename, path: filePath}; } +export function getPreviewImagePath(filename) { + // Returns the path to a preview image that can be used to represent a file. + const fileInfo = splitFileLocation(filename); + const fileType = getFileType(fileInfo.ext); + + if (fileType === 'image') { + return getFileUrl(fileInfo.path + '_preview.jpg'); + } + + // only images have proper previews, so just use a placeholder icon for non-images + return getPreviewImagePathForFileType(fileType); +} + export function toTitleCase(str) { function doTitleCase(txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); @@ -1050,15 +1063,7 @@ export function fileSizeToString(bytes) { // Converts a filename (like those attached to Post objects) to a url that can be used to retrieve attachments from the server. export function getFileUrl(filename) { - var url = filename; - - // This is a temporary patch to fix issue with old files using absolute paths - if (url.indexOf('/api/v1/files/get') !== -1) { - url = filename.split('/api/v1/files/get')[1]; - } - url = getWindowLocationOrigin() + '/api/v1/files/get' + url + '?' + getSessionIndex(); - - return url; + return getWindowLocationOrigin() + '/api/v1/files/get' + filename + '?' + getSessionIndex(); } // Gets the name of a file (including extension) from a given url or file path. |