storeLocation = ?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 yıl önce
I'm trying to insert the CDN link for images (of products and categories).

I tried editing in the page: "Librarias / Nop.Services / Media / PictureService.cs":



//protected virtual string GetThumbUrl(string thumbFileName, string storeLocation = null)
      protected virtual string GetThumbUrl(string thumbFileName, string storeLocation = "cdn-img.r.worldssl.net")
    {
            storeLocation = !string.IsNullOrEmpty(storeLocation)
                                    ? storeLocation
                                    : _webHelper.GetStoreLocation();
            var url = storeLocation + "images/thumbs/";



After these changes I recompiled in Release and then posted on the server.

I deleted the cache, restarted the application and the Application pools on the server.

The result is that nothing has changed. All images always point, as before, to the URL of the site.

Where am I wrong?

Thanks
5 yıl önce
I dont know anything about CDN but I assume you are storing images in file system rather than database ?

    protected virtual string GetThumbUrl(string thumbFileName, string storeLocation = "cdn-img.r.worldssl.net")
    {

The command string storeLocation = "cdn-img.r.worldssl.net" will only be invoked if no parameter is passed in
If null is passed in as a parameter that is what is used and hence it goes to the store location

If you always want to force it to use your location you need to set the parameter you pass in somewhere before the call to this routine

           storeLocation = "http://cdn-img.r.worldssl.net";
5 yıl önce
Hi Ydna and thanks for your reply.

"I assume you are storing images in file system rather than database?"

Yes, I store the images directly in the server (in wwwroot / images /), not in the database.

"We need to set up a routine"

And how should I do it?
5 yıl önce
You switched on Pictures are stored into...file system ?
And you are using a CDN to replicate the files from nopCommerce41\wwwroot\images\thumbs to your CDN Directory ?

I do not know what is involved without doing it but I assume everywhere you are loading files you need to force it to use your CDN directory

Maybe there is more to it ? There are plugins in the marketplace - dont know what else they do

https://www.nopcommerce.com/marketplace.aspx?searchterm=cdn

This one is free maybe have a look what it does

https://www.nopcommerce.com/p/947/nopaccelerate-cdn-free-cdn-plugin-for-nopcommerce.aspx
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.