Skip to content

📸 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

  1. Reads the original image from the $src path.
  2. Resizes the image while maintaining aspect ratio.
  3. Stores the thumbnail in a designated location.
  4. 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.

  • 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.