mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: on OP edit, call helper method to upload and resize thumb
This commit is contained in:
@@ -122,7 +122,11 @@ module.exports = function (Posts) {
|
|||||||
newTopicData.title = title;
|
newTopicData.title = title;
|
||||||
newTopicData.slug = tid + '/' + (slugify(title) || 'topic');
|
newTopicData.slug = tid + '/' + (slugify(title) || 'topic');
|
||||||
}
|
}
|
||||||
newTopicData.thumb = data.thumb || '';
|
|
||||||
|
if (data.thumb) {
|
||||||
|
await topics.resizeAndUploadThumb(data);
|
||||||
|
newTopicData.thumb = data.thumb;
|
||||||
|
}
|
||||||
|
|
||||||
data.tags = data.tags || [];
|
data.tags = data.tags || [];
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ module.exports = function (Topics) {
|
|||||||
const pipeToFileAsync = util.promisify(pipeToFile);
|
const pipeToFileAsync = util.promisify(pipeToFile);
|
||||||
|
|
||||||
Topics.resizeAndUploadThumb = async function (data) {
|
Topics.resizeAndUploadThumb = async function (data) {
|
||||||
|
// Only continue if passed in thumbnail exists and is a URL. A system path means an upload is not necessary.
|
||||||
if (!data.thumb || !validator.isURL(data.thumb)) {
|
if (!data.thumb || !validator.isURL(data.thumb)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user