<?php
namespace CBCdnImagePlugin;
use MagentoCatalogHelperImage;
class ProductImageCdn
{
const CDN_BASE_URL = 'https://cdn.yourstore.com/media/catalog/product/';
public function afterGetUrl(Image $subject, $result)
{
// Only modify product image URLs, not CMS/static images
if (strpos($result, '/catalog/product/') !== false) {
return str_replace('/media/catalog/product/', self::CDN_BASE_URL, $result);
}
return $result;
}
}
I have actually made custom way to call images via CDN whereas the other images for the static pages comes from magento default functionality.
The thing is products are imported through PIM and the images be like
https://media.accell.cloud/Accell/Ghost/GHOST_MY23_E-Teru-B-Essential-EQ_C1_27-5Inch_90_3D_GTBP1.png
which redirects to https://images-p.accell.cloud/-12ANHXHbZFcel9-XeeIPb7mNIUGkJPj304cuwi6UYk//czM6Ly9jczIwLWJ1Y2tldC1wcm9kL0FjY2VsbC9HaG9zdC9HSE9TVF9NWTIzX0UtVGVydS1CLUVzc2VudGlhbC1FUV9DMV8yNy01SW5jaF85MF8zRF9HVEJQMS5wbmc.png
More over I have the control of only read permissions of the contents in CDN.
Help me with solution of using the product images through CDN