mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: #8386, use backgroundImage everywhere
This commit is contained in:
@@ -81,10 +81,6 @@ function modifyCategory(category, fields) {
|
|||||||
category.totalTopicCount = category.topic_count;
|
category.totalTopicCount = category.topic_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (category.image) {
|
|
||||||
category.backgroundImage = category.image;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (category.description) {
|
if (category.description) {
|
||||||
category.description = validator.escape(String(category.description));
|
category.description = validator.escape(String(category.description));
|
||||||
category.descriptionParsed = category.descriptionParsed || category.description;
|
category.descriptionParsed = category.descriptionParsed || category.description;
|
||||||
|
|||||||
23
src/upgrades/1.14.0/fix_category_image_field.js
Normal file
23
src/upgrades/1.14.0/fix_category_image_field.js
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const db = require('../../database');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'Remove duplicate image field for categories',
|
||||||
|
timestamp: Date.UTC(2020, 5, 9),
|
||||||
|
method: async () => {
|
||||||
|
const batch = require('../../batch');
|
||||||
|
await batch.processSortedSet('categories:cid', async function (cids) {
|
||||||
|
let categoryData = await db.getObjects(cids.map(c => 'category:' + c));
|
||||||
|
categoryData = categoryData.filter(c => c && (c.image || c.backgroundImage));
|
||||||
|
if (categoryData.length) {
|
||||||
|
await Promise.all(categoryData.map(async (data) => {
|
||||||
|
if (data.image && !data.backgroundImage) {
|
||||||
|
await db.setObjectField('category:' + data.cid, 'backgroundImage', data.image);
|
||||||
|
}
|
||||||
|
await db.deleteObjectField('category:' + data.cid, 'image', data.image);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}, { batch: 500 });
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -122,14 +122,14 @@
|
|||||||
[[admin/manage/categories:upload-image]]
|
[[admin/manage/categories:upload-image]]
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<!-- IF category.image -->
|
<!-- IF category.backgroundImage -->
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<button class="btn btn-warning delete-image">
|
<button class="btn btn-warning delete-image">
|
||||||
<i data-name="icon" value="fa-times" class="fa fa-times"></i>
|
<i data-name="icon" value="fa-times" class="fa fa-times"></i>
|
||||||
[[admin/manage/categories:delete-image]]
|
[[admin/manage/categories:delete-image]]
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<!-- ENDIF category.image -->
|
<!-- ENDIF category.backgroundImage -->
|
||||||
</div><br />
|
</div><br />
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
@@ -138,7 +138,7 @@
|
|||||||
[[admin/manage/categories:category-image]]
|
[[admin/manage/categories:category-image]]
|
||||||
</label>
|
</label>
|
||||||
<br/>
|
<br/>
|
||||||
<input id="category-image" type="text" class="form-control" placeholder="[[admin/manage/categories:category-image]]" data-name="image" value="{category.image}" />
|
<input id="category-image" type="text" class="form-control" placeholder="[[admin/manage/categories:category-image]]" data-name="backgroundImage" value="{category.backgroundImage}" />
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user