Image relocation!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 years ago
Hey Guys,

You ever noticed how on big e-commerce sites the images are hosted on a separate sub-domain?

I am coding my biggest nopCommerce store yet, and I would like to host the product images on a separate subdomain for performance reasons.

Is there a simple way to do this?  Hopefully a way which will leave the image upload feature in the backend functional?

Thanks! :)
13 years ago
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 :)
13 years ago
thank you :)

I will take a look and see what I can do there...

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

thanks :)
13 years ago
zencart can do but nop looks can't. i need.
11 years ago
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 ?
11 years ago
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?
11 years ago
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.

http://stackoverflow.com/questions/3956505/in-autofac-how-do-i-change-the-instance-that-is-registered-after-build-has-been
11 years ago
Thanks for the info.

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();
11 years ago
Any update here?
11 years ago
You need to add a property to your DependencyRegistrar class to indicate that it is a higher priority than the others.

public int Order
        {
            get { return 1; }
        }


The DependencyRegistrar classes get processed in ascending order so if you make sure your's is at the end it will overwrite any of the others.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.