Media Selection Get File on Custom Webpart

Brendon McCarthy asked on October 8, 2014 21:53

I'm using the MediaSelection form control on a custom webpart. However, I'm not sure how to get the URL of the file/document location. The user could choose to store the file 1) as attachment, 2) in a media library, or 3) as content (file system). The custom webpart does not know where, so which API function would get the URL of the media (in this case audio or video)? The URL needs to be resolvable by a third-party Javascript control (JWPlayer) with the original extension (i.e. mp4).

Recent Answers


Juraj Ondrus answered on December 6, 2014 10:56

Hi Brendon,

You will need to check the saved value for this field.

If you are using permanent URLs for media libraries, the saved URL will be like ~/getmedia/< GUID >. If using direct path - it will be the physical folder path.
If the value is an attachment - the value will be like ~/getattachment/< GUID or path >
And for the CMS.File selection - it will be the node alias path.
So, you need to create a switch statement in which you will check the format of the stored value and then do your logic.

Best regards,
Juraj Ondrus

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.