Dave Burke : Freelance .NET Web Developer specializing in Online Communities

CS Nuglet: Displaying thumbnail image with blog post

This is a fun and easy little mod that displays a thumbnail image with a blog post.  Unlike the mouseover mod I recently added to dbvt.com which pulls a random image from my photo gallery, this mod displays a specific image associated with the post.  The key to the simplicity of the mod is that the image is the post's attachment.


 

We're adding a new "thumbnail" property to our custom Community Server WeblogData control.  You'll notice that I'm using a custom DBVTConfiguration (as a supplement to CSConfiguration) model to store the default thumbnail for posts that do not include a thumbnail attachment.

 

case "thumbnail":
    DBVTConfiguration dbvtConfig = DBVTConfiguration.GetConfig();
    string imageUrl = string.Format("<img src=\"{0}\" border=\"0\" />",
         dbvtConfig.DefaultThumbnailUrl);
    if (!post.HasAttachment)
    return imageUrl;

    if (!post.Attachment.ContentType.StartsWith("image"))
    return imageUrl;

    imageUrl = string.Format("<img src=\"{0}\" border=\"0\" />",
            BlogUrls.Instance().AttachmentUrl(post.Weblog, post.Attachment));
    return imageUrl;

 

Then we modify our postlist page ItemTemplate to display the thumbnail.

 

<ItemTemplate>
<li class="CommonListRow">
<div class="BlogPostThumbnail">
<DBVTControl:WeblogPostData ID="WeblogPostData3"
         runat="server" Property="Thumbnail"  />

</div>
    <div class="BlogPostArea">
    <h4 class="BlogDirectoryPostHeader">
        <DBVTControl:WeblogPostData ID="WeblogPostData1"
              runat="server" Property="Subject" LinkTo="Post" />
    </h4>
    <div class="BlogPostContent">
        <DBVTControl:WeblogPostData ID="WeblogPostData2"
               Property="Excerpt" runat="server" />
    </div>
    </div>
</li>
</ItemTemplate>

Comments (4) | Post RSS RSS comment feed

Posted on 9/5/2007 6:40:41 AM by Dave Burke
Categories: .NET | Community Server
Tags:

Related posts

Comments (4) -

9/5/2007 9:24:34 AM Permalink

I noticed the slide down image mod the other day when looking at your running blog.

Very cool Smile

Shame you don't post slightly higher res photos otherwsie I'd be using them for my desktop background - you seem to take snaps of beatuiful scenary.

Granville Barnett |

9/5/2007 9:36:04 AM Permalink

Granville,  Thanks much!  That's quite a compliment about the photos.  I use a Photoshop macro and scale each one down to 1000 x 750, originally they're 2272 x 1704, the most I can get out of my 4 megapixel Canon A85.  I also brighten and sharpen them up a bit in the process.  I reduce their size for performance, storage and handling reasons and for the primary dbvt.com function of displaying them nicely in a browser window.  If there's a particular image you want let me know and I'll try to track down the original.  Thanks for visiting my running blog.  Speaking of which, it's about that time of day for me to get out there.

daveburke |

9/6/2007 4:48:00 AM Permalink

Hi Dave,

You have too many great photo's, you really have a talent there, although great scenary helps Smile

Keep up the great photo's...and the running of course!  

The gym treadmill is enough for me - I only do 20 mins running per day (apart from 2 days a week where I rest), the rest of my time is weight lifting.

Granville Barnett |

9/6/2007 5:27:57 AM Permalink

Hey, Granville, the trick is the Photoshop macro that brightens, sharpens, hues and reduces, but having good natural material helps.  A number of the 1900 or so photos I have online probably shouldn't be there because of a lack of quality, so I try to be judicious about what I upload.  I also only take local pictures on sunny days for better light.

It's soon Nordic Track (ski machine) time for me, too.  It's starting to get cool here!  

Thanks for the comments and keep in touch.

daveburke |

Pingbacks and trackbacks (1)+


Powered by BlogEngine.NET 2.0.0.36
Theme by Dave Burke