📸 createThumbnail() Function Guide
Overview
The createThumbnail()
function in Merciglobal Cloud ERP is used to generate a thumbnail image from a given source image. This is especially useful in ERP modules like inventory, CRM, or product catalogs where a small preview image is necessary.
This guide is for:
- 🧑💻 Internal Merci Developers
- 💼 Merci Team Salespersons
- 👩💼 Customers customizing or integrating their ERP system
🧩 Function Definition
createThumbnail($src, &$thumbfile, $size = 96)
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
$src |
string | ✅ Yes | Path to the source image file |
$thumbfile |
string | ✅ Yes | Reference variable where the thumbnail path is stored |
$size |
integer | ✅ Yes | Size (width/height) of the thumbnail (default is 96 ) |
⚙️ How It Works
- Reads the original image from the
$src
path. - Resizes the image while maintaining aspect ratio.
- Stores the thumbnail in a designated location.
- Updates the reference variable
$thumbfile
with the thumbnail file path.
✅ Example Usage
$sourceImage = 'uploads/product_images/item123.jpg';
$thumbnailPath = '';
createThumbnail($sourceImage, $thumbnailPath, 120);
echo "Thumbnail created at: " . $thumbnailPath;
💡 Best Practices
- Always validate the
$src
file path before calling the function. - Use optimized image formats (JPG, PNG) for better performance.
- Store generated thumbnails in a cache folder with proper access control.
🔐 Security Note
- Ensure that the function cannot be used to access or overwrite arbitrary files.
- Sanitize inputs when used in web applications.
🧰 Related Features in Merciglobal Cloud ERP
- Product Image Management
- Document Scanning and Previews
- CRM Contact Profile Photos
- Custom Module Image Attachments
📞 Need Help?
For support or integration assistance, contact the Merciglobal Cloud ERP technical team or consult the developer portal.
Merciglobal Cloud ERP – Streamline. Scale. Succeed.