mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 11:05:54 +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; | ||||
| 	} | ||||
|  | ||||
| 	if (category.image) { | ||||
| 		category.backgroundImage = category.image; | ||||
| 	} | ||||
|  | ||||
| 	if (category.description) { | ||||
| 		category.description = validator.escape(String(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]] | ||||
| 							</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> | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user