Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


This forum is in read only mode, you can no longer reply
  • Paul Dermody 31 posts 110 karma points
    Jun 20, 2016 @ 02:38
    Paul Dermody
    0

    How do I get the CDN URL of a cached image?

    Hi,

    I need to create a report with a bunch of images from my site. The images are to be of a certain size so I need to crop them first.

    I have the images stored on Azure Blob Storage and I also have a CDN enabled.

    I would like to put the CDN or at least the Azure storage URL in the report, rather than the original URL with the crop instructions in the URL.

    Is there any way to determine the URL of the cached processed images that a browser would eventually be redirected to?

    Thanks, Paul.

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jun 21, 2016 @ 17:36
    Dennis Aaen
    0

    Hi Paul,

    Have you seen this thread perhaps this can help you a step furhter

    https://our.umbraco.org/forum/extending-umbraco-and-using-the-api/76696-imageprocessor-for-azurecloudstorage-breaks-website

    Hope this helps,

    /Dennis

  • James Jackson-South 489 posts 1747 karma points c-trib
    Jun 22, 2016 @ 01:38
    James Jackson-South
    0

    Hi Paul,

    Opening the image in a new tab will give you the CDN url since it will perform a 302 redirect.

    In the future if you want to render the CDN url directly in your webpage I would advise you to have a look at the Azure CDN Toolkit

    https://our.umbraco.org/projects/developer-tools/azure-cdn-toolkit-for-umbraco/

    One of the overloads within that package allows you to render the CDN url if it exists, falling back to the blob storage url if not propagated.

    @Url.GetCropCdnUrl(Umbraco.TypedMedia(1084), width: 150)
    

    This generates that url by saving the result of the first 302 redirect in the application cache to ensure subsequent redirects are not required.

    Predicting the url itself without testing for the existance is extremely difficult since the generated url depends on multiple factors like filesize, last write time etc.

    Hope that helps

    James

Please Sign in or register to post replies

Write your reply to:

Draft