
<?php
// 1. Add this at the top
require_once __DIR__ . '/config/image_config.php';

// 2. In your upload handler
if (isset($_FILES['productImage'])) {
    $result = uploadProductImage($_FILES['productImage'], $_POST['title']);
    if ($result['success']) {
        $imageFilename = $result['original'];  // Save this
    }
}

// 3. When saving product
$product = [
    'id' => uniqid(),
    'title' => $_POST['title'],
    'image' => $imageFilename,  // Just the filename
    // ... other fields
];

?>
```

**In your `shop.php` or product templates:**
```php
<?php
require_once __DIR__ . '/config/image_config.php';

foreach ($products as $product) {
    // Use this instead of hardcoded paths:
    echo getImageForSection($product['image'], 'shop');
    
    // Or for custom sizes:
    echo getImageDynamic($product['image'], 350, 220);
}
?>
```



```php
<?php
require_once __DIR__ . '/config/image_config.php';

// Upload image and generate variants
uploadProductImage($_FILES['image'], 'product_name');

// Get image URL for a specific section
getImageForSection('product.jpg', 'shop');

// Get image URL for custom dimensions
getImageDynamic('product.jpg', 350, 220);

// Display complete img tag
imageTag('product.jpg', 'product', ['alt' => 'My Product']);

// Check if image exists
if (imageExists('product.jpg')) { ... }

// Get image information
getImageInfo('product.jpg');

// Delete image and all variants
deleteProductImage('product.jpg');

// Maintenance: clean old cached variants
cleanupOldVariants(90);  // Remove variants older than 90 days
?>
```

