Images (thumbnails) are not being generated for presets created by the bulk preset generator.
We've added comprehensive logging and diagnostics to identify why image generation is failing. The code now provides detailed error messages and validates all requirements before attempting to generate images.
-
Enable WordPress Debug Logging
Add these lines to your
wp-config.php:define('WP_DEBUG', true); define('WP_DEBUG_LOG', true); define('WP_DEBUG_DISPLAY', false);
-
Navigate to the Preset Admin Page
Go to:
http://localhost:10003/product/heavy-duty-workbench/?pc-presets-admin=12570 -
Run Preset Generation
- Click "Estimate Valid Presets" to see how many will be generated
- Click "Generate All Presets" to start generation
- Watch the progress in the UI
-
Check the Error Logs
Look in
wp-content/debug.logfor detailed information:tail -f wp-content/debug.log | grep "Image Generator\|Config Builder\|Diagnostic"
You'll see reports like:
=== IMAGE GENERATION DIAGNOSTIC REPORT ===
Preset ID: 12345
Total Layers: 8
User Layers: 3
Visual Layers: 5
Layers with Images: 5
Image IDs Found: 123, 456, 789
Issues to check:
Visual Layers: 0- No visual layers found (images won't generate)Layers with Images: 0- Visual layers exist but have no image IDsISSUES: Image ID XXX is not a valid attachment- Referenced images don't exist
Check for:
Image Generator: Starting image generation for preset #12345
Image Generator: Requirements check failed: [error message]
Common issues:
Neither GD nor Imagick extension is available- Install PHP GD or ImagickUpload directory is not writable- Fix file permissionsNo configuration content available- Configuration wasn't saved properly
Look for:
Config Builder: Building configuration from 3 user choices
Config Builder: Added visual layer 'Visual - Frame' with image ID 123
Config Builder: Built configuration with 3 user layers and 5 visual layers
Issues to check:
- Low or zero visual layers added
- Image IDs showing as 0
- "No image found for choice" messages
Symptom: Log shows Visual Layers: 0
Cause: Product doesn't have visual/display layers configured
Fix:
- Edit the product in WooCommerce
- Go to Product Configurator settings
- Add visual layers (layers with
not_a_choice = true) - Assign images to choices in those layers
Symptom: Visual Layers: 5 but Layers with Images: 0
Cause: Choices in visual layers don't have images assigned
Fix:
- Edit each visual layer
- For each choice, upload and assign an image
- Ensure images are set for the default angle (angle_id = 1)
Symptom: Image ID 123 is not a valid attachment
Cause: Referenced images were deleted or don't exist
Fix:
- Check Media Library for the image
- Re-upload if needed
- Re-assign to the choice in Product Configurator
Symptom: Neither GD nor Imagick extension is available
Cause: PHP doesn't have image processing libraries
Fix:
# For GD (Ubuntu/Debian)
sudo apt-get install php-gd
sudo service apache2 restart
# For Imagick
sudo apt-get install php-imagick
sudo service apache2 restartSymptom: Upload directory is not writable
Cause: File permission issues
Fix:
# Check current permissions
ls -la wp-content/uploads/
# Fix permissions (adjust user/group as needed)
sudo chown -R www-data:www-data wp-content/uploads/
sudo chmod -R 755 wp-content/uploads/Symptom: save_image returned false/null
Possible causes:
- Configuration format doesn't match what MKL PC expects
- Product doesn't have proper configurator settings
- Missing required data in configuration
- Internal MKL PC error
Fix:
- Check that product has Product Configurator enabled
- Verify all layers have proper settings
- Test saving a preset manually through the frontend
- Check MKL PC plugin logs for more details
Add this to your theme's functions.php temporarily:
add_action('admin_init', function() {
if (isset($_GET['check_image_gen'])) {
$status = MKL_PC_Preset_Image_Generator::get_status();
echo '<pre>';
print_r($status);
echo '</pre>';
die;
}
});Then visit: http://localhost:10003/wp-admin/?check_image_gen=1
Try generating an image for a specific preset:
add_action('admin_init', function() {
if (isset($_GET['test_image_gen']) && isset($_GET['preset_id'])) {
$preset_id = intval($_GET['preset_id']);
$result = MKL_PC_Preset_Image_Generator::generate_image($preset_id);
if (is_wp_error($result)) {
echo 'Error: ' . $result->get_error_message();
} else {
echo 'Success! Image ID: ' . $result;
}
die;
}
});Visit: http://localhost:10003/wp-admin/?test_image_gen=1&preset_id=12345
- Enable debug logging
- Run preset generation
- Review the debug log for specific errors
- Apply the appropriate fix from above
- Re-run generation to verify the fix
If the issue persists after trying these fixes:
- Collect the full debug log output
- Note which specific error messages appear
- Check the MKL Product Configurator plugin documentation
- Verify that manual preset creation (without the bulk generator) works and generates images