Nop creates other renditions of images on the fly as it needs them. It would be easy enough to rewrite the image urls before they hit the page, but I think your challenge would be making sure the newly created thumbnails and other images where pushed to the other system as they were uploaded/created.
I would make the changes in NopSolutions.NopCommerce.BusinessLogic.Media.PictureManager in the BusinessLogic project. That class controls on the fly image creation and url forming for all dynamic images so you should be able to change it to be pushing those images to another server (via UNC, FTP, whatever you want just code it in).
Someone else will need to chime in on moving the theme's and other static images to another server. I'm not as familiar with that part yet :)
I'm gonna leave the theme images where they are, cause it's mostly small strips and icons.. nothing big!
Apparently putting your larger images on a different subdomain can help speed up the performance of the site, the browser doesn't go checking for cookies on the subdomain as it loads each image
Sorry to unearth an old post, but I am currently working on a NopCommerce website where we need to use and external server (5 servers all over the world in fact) to store the images.
Does anything as been done in that direction or should I start to look how to do it on my own ?
Also, I want if possible to develop it as a plugin. Meaning I want to be able to activate deactivate on the fly without any change in the code. Currently I found that I could do a plugin and implement IMiscPlugin and IPictureService, and then override the default Picture Service by using a DependencyRegistrar class.
In this class I have basically a line of code to register my plugin : builder.RegisterType<MyPictureService>().As<IPictureService>().InstancePerHttpRequest();
but this override the current PictureService always. Is there a way to implement a switch, to choose which Picture Service implementation we want to use ?
If your DependencyRegistrar is in you new plugin, wouldn't it only be active when the plugin is active? Or does it run any time the plugin is installed?
Here's an interesting idea. Instead of registering your service in your DependencyRegistrar, maybe you could do it when the plugin is installed and revert it back to the standard service when your plugin is uninstalled.
I tried it this way, but after the install of the plugin is done in nopCommerce, all the DependencyRegistrar are called once again and my custom registration is overriden.
I managed to acces the PluginDescriptor of my plugin in my DependencyRegistrar then I can choose to Register or not the service.
// Load the plugin Descriptor Nop.Core.Plugins.PluginDescriptor _pluginDesc = Nop.Core.Plugins.PluginManager.ReferencedPlugins .Where(x => x.ReferencedAssembly == (new MyPictureServicePlugin(null)).GetType().Assembly) .FirstOrDefault();
// Check if plugin exists and is installed if (_pluginDesc != null && _pluginDesc.Installed == true) // register the Picture Service builder.RegisterType<MyPictureServicePlugin>().As<IPictureService>().InstancePerHttpRequest();