This project is read-only.

Blog post won't show images...

Topics: General
May 2, 2012 at 2:07 AM

Hi All,

I can edit a post and insert images just fine. I publish. The post shows on the site but the embedded images do not. The only thing that shows up are empty "p" tags ("img" element somehow gets dropped).

When I go back and edit the post the images show just fine. The image url in the "img" element are good when viewed in the editor and the images uploaded just fine.

Anyone know what's going seems kinda strange that the "img" elements get dropped when viewing a post on the blog.



May 2, 2012 at 2:18 AM

In the post list or in the post details?

May 2, 2012 at 2:43 AM


Well, I just started with Orchard yesterday so please be patient, I'm not sure what "post list" or "post details" is yet. However, here's what shows in the "Edit Blog Post":

<p>Last weekend we were joined by a friend of ours, Takako. She brought her new puppy, MoMo, along for our weekend hike. He's a cute little guy.</p>
<p><br /><img alt="" src="/Media/Default/BlogPost//takako_20120422_1.jpg" align="middle" height="480" width="287" /></p>
<p>Takako and MoMo</p>
<p><img alt="" src="/Media/Default/BlogPost//dogpark_20120422.jpg" height="287" width="480" /></p>
<p>The dogpark on Mullholand Drive</p>

Now, when viewing the post from the Home Page, and looking at the page source, I get:

<ul class="blog-posts content-items"><li class="last first"><article class="content-item blog-post">


 <h1><a href="/takako-has-a-new-friend">Takako Has a New Friend</a></h1>


 <div class="metadata">


 <div class="published">May 1 2012 5:44 PM</div><span class="commentcount">0 Comments</span> 



 <p>Last weekend we were joined by a friend of ours, Takako. She brought her new puppy, MoMo, along for our weekend hike. He's a cute little guy.</p>


<p>Takako and MoMo</p>



<p>The dogpark on Mullholand Drive <a href="/takako-has-a-new-friend">more</a></p>




Note that the image tags have disapeared. Weird.


May 2, 2012 at 2:59 AM

Well, post list is the list of posts on your blog, and post details are the details of your post. What you see on the home page is the list of posts, and it's using a summary template that doesn't show images and shortens the text.

Drop a file named Parts.Common.Body.Summary.cshtml into Views under your theme's directory with this content:

    Orchard.ContentManagement.ContentItem contentItem = Model.ContentPart.ContentItem;
    var bodyHtml = Model.Html.ToString();
    var more = bodyHtml.IndexOf("<!--more-->");
    if (more != -1) {
        bodyHtml = bodyHtml.Substring(0, more);
    else {
        var firstP = bodyHtml.IndexOf("<p>");
        var firstSlashP = bodyHtml.IndexOf("</p>");
        if (firstP >=0 && firstSlashP > firstP) {
            bodyHtml = bodyHtml.Substring(firstP, firstSlashP + 4 - firstP);
    var body = new HtmlString(bodyHtml); 
<p>@Html.ItemDisplayLink(T("Read more...").ToString(), contentItem)</p>

May 2, 2012 at 3:15 AM

Hey, guess worked!!

What if I don't want the "Read more..."? How do I get it to show all?

Thank you so much!

I'm thinking that the theme I'm using didn't have this view.

Actually, I just looked at the 'stock' themes and they don't have it either.


May 2, 2012 at 4:33 AM

If you just want the whole post, change the template to:


May 2, 2012 at 5:03 AM

Thank you so much for your help.

Although, being a newbie to Orchard, what template file are you referring to?


May 2, 2012 at 5:03 AM

The one you just created.

May 2, 2012 at 5:19 AM

Oh. It worked. Thank you very much!