Umbraco Display File Extensions as Image Thumbnails, Using Razor

Example Implementation:




a) The Helper:

@helper DisplayDocImage(string thisExtension)
{
switch (thisExtension)
{
    case "docx":
case "doc":
{
<img src="/media/121912/WORD.png" alt="" />
break;
}
case "xls":
case "xlsx":
{
   <img src="/media/121891/EXCEL.png" alt="" />
break;
}
case "ppt":
case "pptx":
{
   <img src="/media/121905/PPT.png" alt="" />
break;
}
case "pdf":
{
   <img src="/media/121898/PDF.png" alt="" />
break;
}

default:
{

  break;
}


}
}

b) Calling the Helper:

@DisplayDocImage(@thisFile.umbracoExtension)



Comments

Popular posts from this blog

Umbraco - Reset the Admin Password via SQL Server

Create a .NET Contact Form that Gets the Last Url Visited in C# Can also be Used in Umbraco

Umbraco Macro for IFrame when Embedding Video, Vimeo Universal Player, or other types of IFrame on to a Page XSLT version and Razor Version