mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Not breaking media editor for images, and refactoring into ext method.
--HG-- branch : 1.x
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web.Mvc;
|
||||||
using Orchard.Media.Models;
|
using Orchard.Media.Models;
|
||||||
|
|
||||||
namespace Orchard.Media.Helpers {
|
namespace Orchard.Media.Helpers {
|
||||||
@@ -24,5 +26,10 @@ namespace Orchard.Media.Helpers {
|
|||||||
|
|
||||||
return navigations;
|
return navigations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsPicture(this HtmlHelper htmlHelper, string path) {
|
||||||
|
return new[] {".png", ".jpg", ".jpeg", ".gif", ".bmp", ".ico"}
|
||||||
|
.Contains((Path.GetExtension(path) ?? "").ToLowerInvariant());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -5,8 +5,7 @@
|
|||||||
@{
|
@{
|
||||||
Style.Require("MediaAdmin");
|
Style.Require("MediaAdmin");
|
||||||
Layout.Title = T("Edit Media - {0}", Model.Name).ToString();
|
Layout.Title = T("Edit Media - {0}", Model.Name).ToString();
|
||||||
var isPicture = new[] {".png", ".jpg", ".jpeg", ".gif", ".bmp", ".ico"}
|
var isPicture = Html.IsPicture(Model.Name);
|
||||||
.Contains(Path.GetExtension(Model.RelativePath ?? "").ToLowerInvariant());
|
|
||||||
var embedHTML = isPicture ?
|
var embedHTML = isPicture ?
|
||||||
"<img src=\"" + Model.PublicUrl + "\"/>" :
|
"<img src=\"" + Model.PublicUrl + "\"/>" :
|
||||||
"<a href=\"" + Model.PublicUrl + "\">" + Model.Name + "</a>";
|
"<a href=\"" + Model.PublicUrl + "\">" + Model.Name + "</a>";
|
||||||
|
Reference in New Issue
Block a user