This project is read-only.

Extension to show thumbnail in post description

Topics: Controls
Jan 22, 2015 at 11:53 PM
I have looked all through the gallery for an extension to show a small preview of the image on the post. There use to be one called excerptimages, but it's not available anymore. Does anyone have a plugin or a way to show a preview of the image in the post list?

Jan 24, 2015 at 10:24 AM
That was a useful extension.
The BreakPost extension that comes with BE is enabled by default and might do the trick, To use it, make sure "Only show description of posts" in settings is unchecked, then add marker [more] in post body wherever you would like the post truncated for list views, In post lists you will see shortened version of post along with any images that are present before the [more] breakpoint in post body.

If you want to use the "Only show description of posts" option then this will require some coding. here are a couple of examples:

Without regex
With regex

Both examples are a little old now and were intended for previous versions of BE(the newer razor themes are different), but principles are still the same.
The advantage of this approach is that it will give you more control over image size and placement in previews.
Jan 24, 2015 at 8:02 PM
Thanks Andy, I am going with the regex version and it's going ok. Currently my project does not have a code behind page for the PostView.ascx. The page is currently looking at this page:
<%@ Control Language="C#" AutoEventWireup="true" EnableViewState="false" Inherits="BlogEngine.Core.Web.Controls.PostViewBase" %>

How would I go about adding a code behind page for the standard theme?

Thanks again for all your help!

Jan 25, 2015 at 12:01 AM
Hi Joey,

PostView.ascx.cs should look something like this
using System;
using System.Text.RegularExpressions;
using BlogEngine.Core;
using BlogEngine.Core.Web.Controls;

public partial class PostView : PostViewBase
    public string GetYourImage()
        // Stuff      
        return yourImage;
You can copy this into Notepad and save as PostView.ascx.cs and then drop file in your theme folder.

Then change your PostView.ascx to reference the new cs file
<%@ Control Language="C#" AutoEventWireup="true" EnableViewState="false"  CodeFile="PostView.ascx.cs" Inherits="PostView" %>
Fingers crossed.
Jan 26, 2015 at 3:54 AM
Thanks Andy, that worked great!