Developer forum

Forum » Dynamicweb 10 » CDN Issue
Justin Sjouw Dynamicweb Employee
Justin Sjouw
Reply

Hi,

I have set both CDN settings, but only the normal img url seems to be replaced. Is there anything special I need to do to also replace the srcset url? or it this a bug maybe?


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

You need to add to your code-base directly.

 
Joseph Vause
Reply

Hi Nicolai,

What is the purpose of the Host (GetImage.ashx) field if its not to point that function to the CDN, that is the behaviour I would expect?

If not can you point me in the direction to where we can edit that file

Thanks

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

It is the correct purpose - the feature does just not support srcset attribute as it right now...

 
Joseph Vause
Reply

So there is no way currently to point the srcset attribute to use the CDN rather than local file system?

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Joseph

Yes, currently that is correct.

I can see from the template code that this must be Swift. It is simple to modify the 2 templates that use srcset attribute to include the cdn prefix:

You can do something like this in the template:

You need to change these 2 templates

  • \Files\Templates\Designs\Swift\Paragraph\Swift_ProductDefaultImage.cshtml
  • \Files\Templates\Designs\Swift\Paragraph\Swift_ProductListGridView.cshtml

BR Nicolai

Votes for this answer: 1
 
Joseph Vause
Reply

Thank you for your response and potential solution.

Unfortunately Pageview does'nt have CdnHostNameForGetImage as a memeber variable so it errors when trying to render it.

I also believe its the imagePathUrlEncoded that needs changing to point to the CDN rather than chainging the GetImage.ashx location

 
Justin Sjouw Dynamicweb Employee
Justin Sjouw
Reply

Hey Joe, Not sure if I'm talking BS here, but it could be a version thing. I see you are running 10.4.1, do you also have this issue when running 10.6.3?

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply
This post has been marked as an answer

My example was from DW9, you need to get the host like this on DW10:

Dynamicweb.Frontend.PageView.Current().Area.CdnImageHost

You cannot use the CDN host as a prepend of the imagePathUrlEncoded for GetImage like this:

GetImage.ashx?image=https://cdn.host...... as that would not work.

It has to be https://cdn.host.../admin/public/GetImage.ashx?image=somefolder/someimage.jpg - it requires a CDN that supports the proxying of the request like e.g. AWS does.

Otherwise you would have to totally remove the getimage.ashx part and go directly to the CDN - most CDNs these days also support image resizing.

Votes for this answer: 1
 
Joseph Vause
Reply

What we had to use was Dynamicweb.Frontend.PageView.Current().CdnHostNameForImage

but that has now made the GetImage use the cdn for srcset

Thanks!

 

You must be logged in to post in the forum