CrumpledDog / Umbraco-AzureCDNToolkit

Makes it easy to fully utilise the Azure CDN with a Umbraco website
13 stars 14 forks source link

Enabling AzureCDNToolkit in web.config renders incorrect URLs in RTE #4

Closed akuryan closed 7 years ago

akuryan commented 7 years ago

If I set AzureCDNToolkit:UseAzureCdnToolkit in appSettings to True, AzureCDNToolkit starts rendering incorrect URLs in RTE, replacing 'media/' in URI by blob storage container name Here is an example: I've added a media from library as an image to RTE. In backend in src it is seen as <img style="width: 224px; height: 60px; display: block;" src="/media/1068/logo.png?width=224&amp;height=60" alt="" rel="3884" data-id="3884" /> If AzureCDNToolkit:UseAzureCdnToolkit is set to FALSE, then on frontend URL is rendered as <img src="/media/1068/logo.png?width=224&amp;height=60" alt="" data-id="3884"> and on request is redirected to my CDN endpoint with 302 https://my_cdn_endpointazureedge.net/cache/6/5/7/c/c/2/657cc22c67f415d685bf47639035422095d31bb6.png However, if I set AzureCDNToolkit:UseAzureCdnToolkit to TRUE, then my link is rendered as <img src="/umbraco-media-dev/1068/logo.png?width=224&amp;height=60&amp;rnd=131021636310000000" alt="" data-id="3884">, where umbraco-media-dev is my container name.

Jeavon commented 7 years ago

Have you added the

<add key="AzureCDNToolkit:MediaContainer" value="umbraco-media-dev" />

key to your web.config?

akuryan commented 7 years ago

Key? All content in my web config:

    <add key="AzureCDNToolkit:UseAzureCdnToolkit" value="false" />
    <add key="AzureCDNToolkit:Domain" value="https://myHost" />
    <add key="AzureCDNToolkit:CdnUrl" value="https://myCdnEndpoint.azureedge.net" />
    <add key="AzureCDNToolkit:CdnPackageVersion" value="0.0.1" />
    <add key="AzureCDNToolkit:AssetsContainer" value="assets" />
    <add key="AzureCDNToolkit:MediaContainer" value="umbraco-media-dev" />

That's what is coming from transform file:

  <appSettings>
    <add key="AzureCDNToolkit:UseAzureCdnToolkit" value="true" xdt:Locator="Match(key)" xdt:Transform="InsertIfMissing"/>
    <add key="AzureCDNToolkit:Domain" value="http://[mywebsitedomain.com]" xdt:Locator="Match(key)" xdt:Transform="InsertIfMissing"/>
    <add key="AzureCDNToolkit:CdnUrl" value="https://[mycdn].azureedge.net" xdt:Locator="Match(key)" xdt:Transform="InsertIfMissing"/>
    <add key="AzureCDNToolkit:CdnPackageVersion" value="0.0.1" xdt:Locator="Match(key)" xdt:Transform="InsertIfMissing"/>
    <add key="AzureCDNToolkit:AssetsContainer" value="assets" xdt:Locator="Match(key)" xdt:Transform="InsertIfMissing"/>
    <add key="AzureCDNToolkit:MediaContainer" value="media" xdt:Locator="Match(key)" xdt:Transform="InsertIfMissing"/>
  </appSettings>

What is key??

Jeavon commented 7 years ago

strange, what method are you using to retrieve the media path? GetCropCdnUrl or ResolveCdn, could you post the code?

akuryan commented 7 years ago

As I said, this happens in Rich Text field, which we do not process for media items

Jeavon commented 7 years ago

I have been able to reproduce, working on a fix

Jeavon commented 7 years ago

@akuryan could you give 0.2.0-alpha-000046 a try?

akuryan commented 7 years ago

@Jeavon Since I have not seen 0.2.0-alpha-000046 on Nuget.org (I suppose, you are using other feed to publish alpha releases), I cloned latest version and compiled it manually. I can confirm that issue, reported here is gone. Waiting for a Nuget.org release to update my nuget package version

Jeavon commented 7 years ago

@akuryan yes, there is a MyGet feed for pre-releases https://www.myget.org/feed/umbraco-packages/package/nuget/Our.Umbraco.AzureCDNToolkit

Great to hear the fix is working for you though!

akuryan commented 7 years ago

Thank you for pointing this out. I realized how to get Our.Umbraco.AzureCDNToolkit.Core of requred version from MyGet and it solved my problem structurally :) So, I will close this issue