Copied to clipboard

Flag this post as spam?

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


  • John 27 posts 49 karma points
    Oct 19, 2011 @ 16:06
    John
    0

    Media content delivery network

    Hi,

     

    I was looking at hosting the files uploaded in the umbraco media library on a CDN however i have ran into a bit of an issue. I need to change the urls for all media items to cdn.blah.com/media/xxx/yyy.jpg, however i don't fancy going through all the xslt files changing the get media area to include the new host, and should i change this host in the future have to do this all over again. Is there anyway to extend umbraco to have a media base url setting? Or would i need to modifiy the source to achieve this?

    THanks

    John

  • Rodion Novoselov 694 posts 859 karma points
    Oct 20, 2011 @ 02:01
    Rodion Novoselov
    0

    Hi. As a matter of fact existing media types seem to be bound to store physical files in the local filesystem. I suppose that the proper way to achieve your goal would be just creating your own custom media type.

  • Justin Spradlin 139 posts 347 karma points
    Oct 20, 2011 @ 03:08
    Justin Spradlin
    0

    I have been using the universal media picker http://our.umbraco.org/projects/backoffice-extensions/universal-media-picker with the Amazon S3 adapter and it works to server my media from S3 instead of from my main web server. 

  • John 27 posts 49 karma points
    Oct 21, 2011 @ 13:28
    John
    0

    The package above are great but a little bit OTT for my requirement, the CDN automatically pulls the images when they are requested from the main server.

    So i only need to change the www.aaa.com/media/1234/test.jpg to cdn.aaa.com/media/1234/test.jpg

    Which means i just need a media path prefix type variable.

    Has any achieved this, modifiying the core? or using a plugin?

     

    Thanks

    John

     

  • Rodion Novoselov 694 posts 859 karma points
    Oct 21, 2011 @ 13:37
    Rodion Novoselov
    0

    I've just thought - perhaps the simplest choice could be merely modify img's urls on the client with javascript? Sure, a bit clumsy approach, but if you just need a quick result then why not.

    $(function() {
    $('img[src^="/media/"]').each(function() {
    $(this).attr('src', 'http://cdn.aaa.com' + $(this).attr('src'));
    });
    }); 
  • Justin Spradlin 139 posts 347 karma points
    Oct 21, 2011 @ 13:48
    Justin Spradlin
    0

    You could also use the urlrewriting functions built into umbraco, or the UrlRewrite addon for IIS. I will try to dig up an example but the basics of it is that you write a regular expression for the url to match and a replacement regex to map to. I have done this before with one of my sites and it worked nicely. I redirected all requests for www.mysite.com/tests to tests.mysite.com. 

  • John 27 posts 49 karma points
    Oct 21, 2011 @ 17:37
    John
    0

    I think i might have to go with the 301 idea, didn't even think of using them, in an ideal world i'd like the url to correct.

     

Please Sign in or register to post replies

Write your reply to:

Draft