From 239d147d9757c62cbfb6ae7b2900b0e5ace6f71c Mon Sep 17 00:00:00 2001 From: hmhealey Date: Tue, 5 Jan 2016 15:49:45 -0500 Subject: Changed Audio/Video preview to just display a file info when encountering a file that cannot be played --- web/react/utils/utils.jsx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'web/react/utils/utils.jsx') diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx index a808c9be3..41ede7712 100644 --- a/web/react/utils/utils.jsx +++ b/web/react/utils/utils.jsx @@ -527,6 +527,25 @@ 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') { + // This is a temporary patch to fix issue with old files using absolute paths + if (fileInfo.path.indexOf('/api/v1/files/get') !== -1) { + fileInfo.path = fileInfo.path.split('/api/v1/files/get')[1]; + } + fileInfo.path = getWindowLocationOrigin() + '/api/v1/files/get' + fileInfo.path; + + return fileInfo.path + '_preview.jpg?' + getSessionIndex(); + } + + // 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(); -- cgit v1.2.3-1-g7c22 From a6ba1a17fe22a72d7058621cb29e9f60d9de0a08 Mon Sep 17 00:00:00 2001 From: hmhealey Date: Wed, 6 Jan 2016 09:54:05 -0500 Subject: Removed temporary fix for old filenames that used absolute urls pointing to the get file api --- web/react/utils/utils.jsx | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'web/react/utils/utils.jsx') diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx index 41ede7712..e84fdf671 100644 --- a/web/react/utils/utils.jsx +++ b/web/react/utils/utils.jsx @@ -533,13 +533,7 @@ export function getPreviewImagePath(filename) { const fileType = getFileType(fileInfo.ext); if (fileType === 'image') { - // This is a temporary patch to fix issue with old files using absolute paths - if (fileInfo.path.indexOf('/api/v1/files/get') !== -1) { - fileInfo.path = fileInfo.path.split('/api/v1/files/get')[1]; - } - fileInfo.path = getWindowLocationOrigin() + '/api/v1/files/get' + fileInfo.path; - - return fileInfo.path + '_preview.jpg?' + getSessionIndex(); + return getFileUrl(fileInfo.path + '_preview.jpg'); } // only images have proper previews, so just use a placeholder icon for non-images @@ -1069,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. -- cgit v1.2.3-1-g7c22