6

I have to create an application using SDL Tridion 2013 (without DD4T). I want to use SDL Media Manager to manage the images and video contents for my application. Now the issue is I am able to retrieve the CDN url of MM items from application but unable to resolve it.

Please suggest what are the possible way to handle this situation.

  • Could you explain what you mean by "resolve"? If you have the CDN URL of the item what more do you need on the content delivery side? – Bjørn van Dommelen Aug 28 '15 at 7:20
  • Resolved means I want the preview url(Resolved). for Example - abc.dist.sdlmedia.com/Distributions/… - This is the distribution url. Now once I hit the url on browser, this url get resolved and provide the below url - abc.ssl.cdn.sdlmedia.com/image/635699714447784833LE.jpg – Sayantan Basu Aug 28 '15 at 7:24
  • 2
    I think that using the distribution URL in an img src attibute is fine, no need to "resolve" the url. Any reason why you would need the actual image url? You can also try to get the JSON output of the distribution if you want to parse it and get a thumbnail or specific renditions of that image if those have been configured in media manager. Just replace "Distributions/?o=" by "json/" in the distribution url to get the JSON output. – Philippe Conil Aug 28 '15 at 9:53
  • 1
    @PhilippeConil you should promote your comment to an answer as I believe it is one :) – Bjørn van Dommelen Aug 28 '15 at 11:43
  • Thanks Bjorn I just did although the correct answer was already given :) – Philippe Conil Aug 28 '15 at 14:28
4

If for whatever reason you want to "resolve" a Media Manager distribution URL, i.e. you want to get the redirected URL, you can achieve this with the following code snippet:

var distributionUrl = "http://blah/blah";
var request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(distributionUrl);
request.AllowAutoRedirect = true;
var response = request.GetResponse();
var resolvedUrl = response.ResponseUri.AbsoluteUri;
  • Thanks Hoang for your response. I have used the below code which is similar to this and it is also working fine. WebRequest webRequest = WebRequest.Create(cdnurl); HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse(); var resolvedUrl = response.ResponseUri.AbsoluteUri; – Sayantan Basu Aug 28 '15 at 12:29
4

When in the CM, you can use the ECL API to check the IContentLibraryMultimediaItem.DisplayTypeId, this will tell you if the item is actually an image or a video (or audio, or download item).

For DXA we are planning to add full support of Media Manager items in the upcoming version 1.2, which means we will add full ECL support in DD4T as part of that process. You can follow the progress on that via our GitHub fork https://github.com/sdl/DD4T.TridionTemplates/tree/feature/ecl-data

Now since you indicate you are not using DD4T, you will have to sort this process out yourself, but could probabaly use some of the approach we do there.

3

I think that using the distribution URL in an img src attibute will work just fine, no need to "resolve" the url.

You can also get the JSON output of the distribution if you want to parse it and get a thumbnail or specific renditions of that image (if those have been configured in media manager). For that, just replace "Distributions/?o=" by "json/" in the distribution url to get the JSON output. It is typically used to create custom media galleries, add effects on videos, create a custom video player and more.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.