How to Prevent Image Duplicates
Goal: Configure cobby to overwrite existing images instead of creating duplicates with numbered suffixes when updating images with the same filename.
Problem
By default, Magento renames new images when an image with the same name already exists:
- Original:
product.jpg - Update attempt creates:
product_1.jpg - Next update creates:
product_2.jpg
This behavior fills your server with orphaned image files over time, especially when you only want to update an existing image (e.g., improved resolution, added text, color correction).
Solution
cobby provides a setting to overwrite existing images instead of creating duplicates.
Prerequisites
- Access to Magento Admin panel
- Administrator permissions for System Configuration
- cobby extension installed
Steps
1. Access Magento Admin
- Log into your Magento Admin panel
- Navigate to System → Configuration
- In the left sidebar, expand Services
- Click on cobby
2. Open Advanced Settings
- Scroll down to the Advanced section
- Click to expand if not already open

3. Configure Overwrite Setting
Locate the Overwrite images option:
Set to "Yes" to overwrite:
- Newly uploaded images replace existing files
- Same filename = file gets overwritten
- No numbered suffixes added
- Keeps server clean and organized
Set to "No" for default behavior:
- Magento adds underscore and number to duplicate filenames
- Original files are preserved
- Example:
image.jpg,image_1.jpg,image_2.jpg
4. Save Configuration
- Click Save Config button at the top right
- Clear Magento cache if prompted
- The setting applies immediately to all future image uploads
How It Works
With Overwrite Enabled (Yes)
Scenario: Update product image with better resolution
- Original image:
product.jpg(200KB) - Upload new image:
product.jpg(800KB) - Result: Original file replaced with new 800KB version
- Server contains only one
product.jpg
With Overwrite Disabled (No)
Same scenario:
- Original image:
product.jpg(200KB) - Upload new image:
product.jpg(800KB) - Result: New file saved as
product_1.jpg - Server contains both
product.jpgandproduct_1.jpg - Original 200KB file becomes orphaned
Use Cases
Enable Overwrite When:
Updating image quality:
- Replacing low-res with high-res versions
- Updating product photos seasonally
- Correcting image defects
Maintaining clean server:
- Want to avoid orphaned files
- Managing server storage space
- Keeping media library organized
Consistent image updates:
- Regularly updating product images
- Synchronized image naming across systems
- Automated image import processes
Disable Overwrite When:
Preserving history:
- Need to keep previous image versions
- Want rollback capability
- Maintaining image archives
Testing variations:
- Comparing different image versions
- A/B testing product photos
- Reviewing image changes before committing
Multiple image versions:
- Intentionally maintaining variations
- Different images for different contexts
- Backup image strategy
Impact on Existing Images
Important: This setting only affects new image uploads:
- Existing duplicate files remain on server
- Does not automatically clean up old duplicates
- Only prevents future duplicates
To clean up existing duplicates:
- Manually review media/catalog/product folder
- Identify unused image files
- Remove orphaned images carefully
- Backup before deleting
Troubleshooting
Setting not working
- Clear Magento cache after changing setting
- Verify you have admin permissions
- Check that cobby extension is up to date
- Test with a new image upload
Images still being numbered
- Verify setting is set to "Yes"
- Check that you saved the configuration
- Ensure image filename matches exactly (case-sensitive)
- Clear browser cache and retry
Original images not updating
- Verify overwrite is enabled
- Check file permissions on media folder
- Ensure new image has exact same filename
- Review server logs for errors
Lost images after enabling
- This is expected behavior when overwriting
- Create backups before enabling
- Test on staging environment first
- Consider whether you need version history
Best Practices
Before Enabling
-
Backup your media folder:
- Create full backup of media/catalog/product
- Store backup in secure location
- Document backup date and contents
-
Test on staging:
- Enable setting on staging environment
- Test image upload and replacement
- Verify functionality works as expected
-
Document your process:
- Create internal documentation
- Train team on new behavior
- Establish image update procedures
After Enabling
-
Monitor server space:
- Track media folder size over time
- Verify no accumulation of duplicates
- Schedule periodic media audits
-
Maintain naming conventions:
- Use consistent image filenames
- Document naming standards
- Ensure team follows conventions
-
Regular cleanup:
- Periodically review media folder
- Remove orphaned images from before setting change
- Optimize storage usage
Version Control Alternative
If you need both clean storage and version history:
- Keep overwrite enabled
- Maintain image versions outside Magento
- Use version control system (Git) for images
- Or use external DAM (Digital Asset Management) system
Additional Notes
Performance: Overwriting images has no performance impact compared to creating duplicates.
Cache: After overwriting images, clear:
- Magento cache
- CDN cache (if applicable)
- Browser cache for testing
Compatibility: This setting works with:
- All cobby versions with advanced settings
- Magento 1 and Magento 2
- All image upload methods (manual, import, API)