Where To Insert Your Custom Php Code

Hello. I am using cs-cart 4.11.5 version, type ULTIMATE.

I need to optimize images with a custom php script, but I don't know where I can use this code on the cs-cart system.

I know I can buy a plugin for this, but I need to use my code. For example, I have a php code (algorithm), and I need to run it. Where can I paste my php code with the image optimization algorithm?

Thanks.

You can use My changes module and create special controller there. It should get all images data from database and run optimization for each image