If you have ever needed to serve PrestaShop product images from a CDN or an external storage service, the old approach meant overriding the Link class, a maintenance headache that breaks on every major update. PrestaShop 9 fixes this cleanly with the overrideImageLink hook.
Here is exactly how it works and how to implement it.
If you are leading PrestaShop Development Agency in France or PrestaShop Development Company in the USA this guide covers “How to Customize Product Image URLs in PrestaShop 9 Without Overrides” so without waiting further let’s get started!
What is the overrideImageLink Hook in PrestaShop 9
PrestaShop 9 introduced a cleaner way to control product image URLs. The overrideImageLink hook lets your module intercept URL generation at the source before the path ever reaches your storefront or back office and return a completely custom URL instead.
PrestaShop triggers this hook every time the Link class generates a product image URL, which means your logic runs automatically across the entire store product pages, category listings, cart thumbnails, and the back office product grid.
Why Avoid Core Overrides for Image URL Customization?
Overriding the Link class in PrestaShop has always worked. It has also always been a problem waiting to happen.
Every PrestaShop Upgrade or PrestaShop Migration that touches the Link class risks breaking your override. You either skip updates to protect the override, or you update and spend hours reconciling conflicts. Neither option is acceptable for a production store.
The overrideImageLink hook eliminates that entirely. Your module plugs into the core process without touching it. Updates apply cleanly. Your customization stays intact.
3 Real Scenarios Where This Hook Makes the Difference.
1) CDN Integration for PrestaShop Product Images
If your store serves customers globally, origin server image delivery is a bottleneck. Integrating Cloudflare, AWS CloudFront, or any CDN means images load from the nearest edge location not your hosting server in a single geography.
The overrideImageLink hook makes this a module-level configuration, not a server-level hack.
2) External Image Storage with AWS S3 or Google Cloud
Storing product images on your main hosting increases storage costs and backup complexity. Moving images to AWS S3 or Google Cloud Storage and routing URLs through this hook keeps your hosting lean without changing how PrestaShop handles images internally.
3) Image Optimization Routing in PrestaShop 9
Some stores route image requests through optimization services that handle WebP conversion, responsive sizing, and compression automatically. The hook gives you the URL control to make that routing transparent to PrestaShop’s core.
How to Implement overrideImageLink in Your PrestaShop 9 Module
Step 1: Register the Hook
$this->registerHook('overrideImageLink');
If your module is already installed, run the registration manually through your module’s configuration or re-install.
Step 2: Write the Hook Function
public function hookOverrideImageLink(array $params)
{
if (empty($params['ids'])
|| empty($params['type'])
|| empty($params['extension'])) {
return;
}
$imageId = $params['ids'];
$imageType = $params['type'];
$extension = $params['extension'];
// Pull CDN base URL from module config
$cdnBase = Configuration::get('MY_MODULE_CDN_URL')
?: 'https://cdn.yourdomain.com';
// Rebuild PrestaShop's standard image folder path
$imagePath = '/img/p/'
. implode('/', str_split($imageId))
. '/' . $imageId . '-' . $imageType . '.' . $extension;
return $cdnBase . $imagePath;
}
Step 3: Configure Your CDN Base URL
Store your CDN domain in PrestaShop’s configuration table via your module settings. This way you can change the CDN endpoint without touching code:
Configuration::updateValue('MY_MODULE_CDN_URL', 'https://cdn.yourdomain.com');
PrestaShop Hook Parameters Explained: Complete Developer Guide
When overrideImageLink is triggered, PrestaShop provides four parameters within the $params array:
- ids — Unique identifier of the image used to reconstruct PrestaShop’s nested storage structure.
- type — Defines the image size variant (e.g., home_default, large_default, medium_default).
- extension — Specifies the file format of the image such as jpg or png.
- name — Optional parameter representing the image filename, may not always be present.
Before and After: URL Transformation Example
Original URL generated by PrestaShop:
https://myshop.com/img/p/1/2/12-home_default.jpg
After the hook processes it:
https://cdn.yourdomain.com/img/p/1/2/12-home_default.jpg
Need a PrestaShop Development Company for Your Project?
If you are planning a PrestaShop 9 migration, CDN integration, or custom module development and want it built properly the first time, our certified PrestaShop developers work on exactly these kinds of projects.
iCreativeTechnologies offers dedicated PrestaShop development services for stores in the USA, UK, and globally from custom PrestaShop module development and performance optimization to full store builds and ongoing technical support.
Frequently Asked Questions
No. This hook was introduced in PrestaShop 9.0.0. If you are running PrestaShop 8, the override approach or a custom Link class modification are your current options.
No. The overrideImageLink hook is specifically for product images. Category images, manufacturer images, and supplier images are generated through separate methods and are not intercepted by this hook.
The overrideImageLink hook is a native feature introduced in PrestaShop 9 that allows developers to customize product image URLs dynamically without modifying core classes. It intercepts the image URL generation process and enables returning a completely custom URL, making it ideal for CDN integration or external storage.
Yes, this hook is specifically useful for CDN integration. It allows you to replace the default image URL with a CDN-based URL, ensuring faster global delivery, reduced server load, and improved performance.
No, this hook was introduced in PrestaShop 9. It is not available in earlier versions, where developers must rely on overrides or custom modifications.