mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-06 23:59:46 +02:00
closes #4650
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
"use strict";
|
||||
|
||||
var fs = require('fs'),
|
||||
path = require('path'),
|
||||
async = require('async'),
|
||||
nconf = require('nconf'),
|
||||
winston = require('winston'),
|
||||
file = require('../../file'),
|
||||
image = require('../../image'),
|
||||
plugins = require('../../plugins');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var async = require('async');
|
||||
var nconf = require('nconf');
|
||||
var winston = require('winston');
|
||||
var file = require('../../file');
|
||||
var image = require('../../image');
|
||||
var plugins = require('../../plugins');
|
||||
|
||||
var allowedImageTypes = ['image/png', 'image/jpeg', 'image/pjpeg', 'image/jpg', 'image/gif', 'image/svg+xml'];
|
||||
|
||||
@@ -124,6 +124,10 @@ uploadsController.uploadDefaultAvatar = function(req, res, next) {
|
||||
upload('avatar-default', req, res, next);
|
||||
};
|
||||
|
||||
uploadsController.uploadOgImage = function(req, res, next) {
|
||||
upload('og:image', req, res, next);
|
||||
};
|
||||
|
||||
function upload(name, req, res, next) {
|
||||
var uploadedFile = req.files.files[0];
|
||||
|
||||
|
||||
@@ -25,14 +25,14 @@ categoriesController.list = function(req, res, next) {
|
||||
content: 'website'
|
||||
}];
|
||||
|
||||
if (meta.config['brand:logo']) {
|
||||
var brandLogo = meta.config['brand:logo'];
|
||||
if (!brandLogo.startsWith('http')) {
|
||||
brandLogo = nconf.get('url') + brandLogo;
|
||||
var ogImage = meta.config['og:image'] || meta.config['brand:logo'] || '';
|
||||
if (ogImage) {
|
||||
if (!ogImage.startsWith('http')) {
|
||||
ogImage = nconf.get('url') + ogImage;
|
||||
}
|
||||
res.locals.metaTags.push({
|
||||
property: 'og:image',
|
||||
content: brandLogo
|
||||
content: ogImage
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -170,8 +170,10 @@ topicsController.get = function(req, res, callback) {
|
||||
var ogImageUrl = '';
|
||||
if (topicData.thumb) {
|
||||
ogImageUrl = topicData.thumb;
|
||||
} else if (postAtIndex && postAtIndex.user && postAtIndex.user.picture){
|
||||
} else if (postAtIndex && postAtIndex.user && postAtIndex.user.picture) {
|
||||
ogImageUrl = postAtIndex.user.picture;
|
||||
} else if (meta.config['og:image']) {
|
||||
ogImageUrl = meta.config['og:image'];
|
||||
} else if (meta.config['brand:logo']) {
|
||||
ogImageUrl = meta.config['brand:logo'];
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user