Not breaking media editor for images, and refactoring into ext method.

--HG--
branch : 1.x
This commit is contained in:
Bertrand Le Roy
2012-08-12 17:17:08 -07:00
parent 7e3453d26e
commit 9d0cc7b3a5
2 changed files with 8 additions and 2 deletions

View File

@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web.Mvc;
using Orchard.Media.Models;
namespace Orchard.Media.Helpers {
@@ -24,5 +26,10 @@ namespace Orchard.Media.Helpers {
return navigations;
}
public static bool IsPicture(this HtmlHelper htmlHelper, string path) {
return new[] {".png", ".jpg", ".jpeg", ".gif", ".bmp", ".ico"}
.Contains((Path.GetExtension(path) ?? "").ToLowerInvariant());
}
}
}

View File

@@ -5,8 +5,7 @@
@{
Style.Require("MediaAdmin");
Layout.Title = T("Edit Media - {0}", Model.Name).ToString();
var isPicture = new[] {".png", ".jpg", ".jpeg", ".gif", ".bmp", ".ico"}
.Contains(Path.GetExtension(Model.RelativePath ?? "").ToLowerInvariant());
var isPicture = Html.IsPicture(Model.Name);
var embedHTML = isPicture ?
"<img src=\"" + Model.PublicUrl + "\"/>" :
"<a href=\"" + Model.PublicUrl + "\">" + Model.Name + "</a>";