diff --git a/BlogEngine/BlogEngine.Core/Post.cs b/BlogEngine/BlogEngine.Core/Post.cs
index 338dc0253..fed08b3ea 100644
--- a/BlogEngine/BlogEngine.Core/Post.cs
+++ b/BlogEngine/BlogEngine.Core/Post.cs
@@ -8,6 +8,7 @@
using System.Linq;
using System.Net.Mail;
using System.Text;
+ using System.Text.RegularExpressions;
using System.Web;
using BlogEngine.Core.Data.Models;
@@ -694,28 +695,27 @@ public bool IsVisibleToPublic
}
///
- /// URL of the first image in the post, if any
+ /// URL of the first image in the post, if any.
+ /// If there's no first image, returns the URL to "images/defaultImg.jpg" in the current theme used in the blog
///
public string FirstImgSrc
{
get
{
- int idx = Content.IndexOf("
", RegexOptions.Multiline | RegexOptions.IgnoreCase);
+ if (match.Success)
{
- idx = idx + 10;
- var idxEnd = Content.IndexOf("\"", idx);
- if (idxEnd > idx)
- {
- var len = idxEnd - idx;
- return Content.Substring(idx, len);
- }
+ srcValue = match.Groups[2].Value;
}
- catch (Exception) { }
}
- return "";
+ if (string.IsNullOrEmpty(srcValue))
+ {
+ srcValue = Utils.RelativeWebRoot + "Custom/Themes/" + BlogSettings.Instance.Theme + "/images/defaultImg.jpg";
+ }
+ return srcValue;
}
}
diff --git a/BlogEngine/BlogEngine.Core/Properties/AssemblyInfo.cs b/BlogEngine/BlogEngine.Core/Properties/AssemblyInfo.cs
index 27a07ffd2..0bc198c31 100644
--- a/BlogEngine/BlogEngine.Core/Properties/AssemblyInfo.cs
+++ b/BlogEngine/BlogEngine.Core/Properties/AssemblyInfo.cs
@@ -20,4 +20,4 @@
[assembly: ComVisible(false)]
[assembly: AllowPartiallyTrustedCallers]
[assembly: AssemblyVersion("3.3.8.0")]
-[assembly: SecurityRules(SecurityRuleSet.Level1)]
+[assembly: SecurityRules(SecurityRuleSet.Level1)]
\ No newline at end of file