Thumbnail Regeneration
Overview
When you update the thumbnailSize configuration for a module, all existing thumbnails for items in that module need to be regenerated to match the new dimensions.
How to Use
1. Update Module Configuration
First, update the module's thumbnailSize in the database:
// Example: Update thumbnailSize for a module
{
"config": {
"thumbnailSize": {
"width": 400,
"height": 400
}
}
}
2. Regenerate All Thumbnails
After updating the configuration, call the regeneration endpoint:
Endpoint: POST /api/module/:moduleId/regenerate-thumbnails
Authentication: Requires inleedMaster authentication
Example Request:
curl -X POST http://localhost:3000/api/module/YOUR_MODULE_ID/regenerate-thumbnails \
-H "Authorization: Bearer YOUR_TOKEN"
Response:
{
"message": "Thumbnails regenerated",
"regeneratedCount": 15,
"errorCount": 0,
"totalItems": 15,
"thumbnailSize": {
"width": 400,
"height": 400
}
}
What Happens
- The endpoint fetches the module's current
thumbnailSizeconfiguration (using.lean()to bypass cache) - Finds all items belonging to that module that have files
- For each item:
- Deletes the old thumbnail file (both filesystem and database)
- Generates a new thumbnail using the updated dimensions
- Saves the new thumbnail file
- Updates the item's thumbnail URL
- Returns statistics about the regeneration process
Supported Module Types
The following module types support thumbnail regeneration:
- news
- product
- event
- job
- partner
- room
- vehicle
- wine
- booklet
- poll
- realEstateProperty
- category
Notes
- The regeneration process uses the first file in each item's files array to generate the thumbnail
- Old thumbnails are automatically deleted before creating new ones
- If an item has no files, it will be skipped
- Errors for individual items are logged but don't stop the entire process
- A log entry is created tracking the regeneration operation