diff --git a/src/meta.js b/src/meta.js index 771839e684..90e581c4bb 100644 --- a/src/meta.js +++ b/src/meta.js @@ -81,11 +81,21 @@ var utils = require('./../public/src/utils.js'), if (fs.existsSync(config)) { fs.readFile(config, function (err, file) { var configObj = JSON.parse(file.toString()); - if (!configObj.screenshot) { + if (configObj.staticDir && configObj.screenshot) { + // Verify that the provided path leads to a file that exists + fs.exists(path.join(__dirname, '../node_modules/', configObj.id, configObj.staticDir, configObj.screenshot), function(exists) { + if (exists) { + configObj.screenshot = path.join('/css/assets/', configObj.screenshot); + } else { + configObj.screenshot = nconf.get('relative_path') + '/images/themes/default.png'; + } + + next(err, configObj); + }); + } else { configObj.screenshot = nconf.get('relative_path') + '/images/themes/default.png'; + next(err, configObj); } - - next(err, configObj); }); } else { next();