diff --git a/src/coverPhoto.js b/src/coverPhoto.js index 4c7afb21eb..c1ceb31133 100644 --- a/src/coverPhoto.js +++ b/src/coverPhoto.js @@ -15,19 +15,24 @@ coverPhoto.getDefaultProfileCover = function (uid) { }; function getCover(type, id) { + const defaultCover = nconf.get('relative_path') + '/assets/images/cover-default.png'; if (meta.config[type + ':defaultCovers']) { - var covers = meta.config[type + ':defaultCovers'].trim().split(/[\s,]+/g); + var covers = String(meta.config[type + ':defaultCovers']).trim().split(/[\s,]+/g); + let coverPhoto = defaultCover; + if (!covers.length) { + return coverPhoto; + } if (typeof id === 'string') { id = (id.charCodeAt(0) + id.charCodeAt(1)) % covers.length; } else { id %= covers.length; } - if (!covers[id].startsWith('http')) { - covers = nconf.get('relative_path') + covers[id]; + if (covers[id] && !covers[id].startsWith('http')) { + coverPhoto = nconf.get('relative_path') + covers[id]; } - return covers; + return coverPhoto; } - return nconf.get('relative_path') + '/assets/images/cover-default.png'; + return defaultCover; }