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)
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
Post a Comment