fix: #8386, use backgroundImage everywhere

v1.18.x
Barış Soner Uşaklı 5 years ago
parent 6a96944247
commit 8627bee541

@ -81,10 +81,6 @@ function modifyCategory(category, fields) {
category.totalTopicCount = category.topic_count;
}
if (category.image) {
category.backgroundImage = category.image;
}
if (category.description) {
category.description = validator.escape(String(category.description));
category.descriptionParsed = category.descriptionParsed || category.description;

@ -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]]
</button>
</div>
<!-- IF category.image -->
<!-- IF category.backgroundImage -->
<div class="btn-group">
<button class="btn btn-warning delete-image">
<i data-name="icon" value="fa-times" class="fa fa-times"></i>
[[admin/manage/categories:delete-image]]
</button>
</div>
<!-- ENDIF category.image -->
<!-- ENDIF category.backgroundImage -->
</div><br />
<fieldset>
@ -138,7 +138,7 @@
[[admin/manage/categories:category-image]]
</label>
<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>
</fieldset>

Loading…
Cancel
Save