Media file extension in transformation

Raj koppola asked on August 12, 2014 16:29

I am working on a carousal that has both images and videos. Basic repeater is used to display the information. I have access to the following url which has parameters width, height and ext. How can I access the ext value in the transformation? So based on the file extension, we will use either image or video tag.

~/getattachment/585d91b2-5d71-44ac-b69a-00a49634dc7a/samsung_led_hdtv.jpg.aspx?width=698&height=215&ext=.jpg

Correct Answer

Raj koppola answered on August 13, 2014 18:09

None of the above worked but I used the following code to parse the url and get the parameter value in the transformation.

<%# getFileType(GetAbsoluteUrl(Eval("Media",true).ToString()))%>
<script runat="server" >
   protected string getFileType(string URL)
    {
        Uri myUri = new Uri(URL);      
        if(HttpUtility.ParseQueryString(myUri.Query).Get("amp;ext")==".jpg"){
          return "image";
        }      
      return "video";
    }
</script>
0 votesVote for this answer Unmark Correct answer

Recent Answers


Brenden Kehren answered on August 13, 2014 00:16 (last edited on June 26, 2015 14:31)

You should be able to use Eval("FileExtension") or Eval("FileMimeType") or simply use the querystring (as a last resort Request.QueryString["ext"]

0 votesVote for this answer Mark as a Correct answer

Raj koppola answered on August 13, 2014 18:07 (last edited on June 26, 2015 14:31)

None of the above worked but I used the following code to parse the url and get the parameter value in the transformation.

<%# getFileType(GetAbsoluteUrl(Eval("Media",true).ToString()))%>
<script runat="server" >
   protected string getFileType(string URL)
    {
        Uri myUri = new Uri(URL);      
        if(HttpUtility.ParseQueryString(myUri.Query).Get("amp;ext")==".jpg"){
          return "image";
        }      
      return "video";
    }
</script>
0 votesVote for this answer Mark as a Correct answer

Kayla Johnson answered on October 25, 2017 23:50

Eval("FileExtension") returns nothing

0 votesVote for this answer Mark as a Correct answer

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