-
-
Notifications
You must be signed in to change notification settings - Fork 376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No images in excerpt #207
Comments
I also need this... There should be an optional intro image property on the Post Model. I have tried to figure this out, but it is beyond me. |
I don't know if this is helpful at all, but I ran into this issue and added a helper function to post.cshtml to get the source of the first image in the post. Invoked using @MarkupHelper.GetPic(Model.Content): @functions{
public class MarkupHelper
{
public static System.Xml.XPath.XPathDocument GetDoc(string markup)
{
try
{
StringReader stringReader = new StringReader(markup);
System.Xml.XPath.XPathDocument xPathdocument;
using (System.Xml.XmlReader xmlReader = System.Xml.XmlReader.Create(stringReader,
new System.Xml.XmlReaderSettings() { ConformanceLevel = System.Xml.ConformanceLevel.Fragment }))
{
xPathdocument = new System.Xml.XPath.XPathDocument(xmlReader);
}
return xPathdocument;
}
catch
{
System.Xml.XmlReader xmlReader = System.Xml.XmlReader.Create(new StringReader(""));
return new System.Xml.XPath.XPathDocument(xmlReader);
}
}
public static string GetPic(string markup)
{
System.Xml.XPath.XPathNavigator nav = GetDoc(markup).CreateNavigator();
System.Xml.XPath.XPathNavigator node = nav.SelectSingleNode("//img/@src");
return node == null ? "" : node.Value;
}
}
} |
@m1kjay This is awesome, I was figuring on server side how to extract single image to use in OffCanvas theme. @if(string.IsNullOrWhiteSpace(MarkupHelper.GetPic(Model.Content))!=null && MarkupHelper.GetPic(Model.Content).ToString()!="") |
First of all thank you for making such a compact, easy blog! I've been trying to put a preview image in the excerpt section but it just pastes it into the body of the post instead. I'm not sure if this is an issue exactly, but is there anyway to have images on the preview part of the posts where it usually just shows the excerpt?
The text was updated successfully, but these errors were encountered: