Images in forum posts?

8 years ago
Can you add images to forum posts? I have tried the BBC code with no luck.
8 years ago
No, out of the box. You need to add [img] BB code support
8 years ago
Can you direct me where I could find information on how to do this?
8 years ago
Look at \src\Libraries\Nop.Core\Html\BBCodeHelper.cs file
8 years ago
Thanks Andrei,

I check it out and added the code needed. You might think about adding it to the next version. We use the forum mainly support and need the function of being about to post images. In my case I also removed the code function because we do not deal with code and have no need for anyone to post it in our forum.

For those that are interested in it, here is what I did for version 2.2

Edit file: ~\Libraries\Nop.Core\Html\BBCodeHelper.cs
private static readonly Regex regexQuote = new Regex(@"\[quote=(.+?)\](.+?)\[/quote\]", RegexOptions.Compiled | RegexOptions.IgnoreCase);
// Added for Image - Brian Weston 11/01/2011
        private static readonly Regex regexImg = new Regex(@"\[img\](.+?)\[/img\]", RegexOptions.Compiled | RegexOptions.IgnoreCase);
// END
        #endregion

// Added Replacement for image
            if (replaceImg)
            {
                // format the img tags:
                // becomes: <img src="Content/Images/ClosedHeader.jpg"></img>
                text = regexImg.Replace(text, "<img src=\"$1\" rel=\"nofollow\"></img>");
            }
// END

            return text;


Edit file: ~\Libraries\Nop.Core\Html\HtmlHelper.cs
                if (convertPlainTextToHtml)
                {
                    text = HtmlHelper.ConvertPlainTextToHtml(text);
                }
// Added true for each intance
                if (allowBBCode)
                {
                    text = BBCodeHelper.FormatText(text, true, true, true, true, true, true, true);
                }
//END
                if (resolveLinks)
                {
                    text = ResolveLinksHelper.FormatText(text);
                }


Edit file: ~\Presentation\Nop.Web\Content\editors\BBEditor\ed.js
/* Added Button Image in Editor */
    document.write("<img class=\"button\" src=\"" + webRoot + "editors/BBEditor/images/picture.gif\" name=\"btnImg\" onClick=\"doAddTags('','" + obj + "')\">");
/* END */
8 years ago
Excellent post, that saved me allot of work thank you.
7 years ago
Don't forget in BBHelper

public static string FormatText(string text, bool replaceBold, bool replaceItalic,
            bool replaceUnderline, bool replaceUrl, bool replaceCode, bool replaceQuote, bool replaceImg)
6 years ago
I have used this code change up to Nop 3.2 for me.
6 years ago
if (replaceImg)
... must before
if (replaceUrl)
...

and also

public static string FormatText(string text, bool replaceBold, bool replaceItalic,
            bool replaceUnderline, bool replaceImg, bool replaceUrl, bool replaceCode, bool replaceQuote)
6 years ago
I added the code and also recommendations by thrifty34 and kupala, but code not work yet. Output not convert  to <img>  html tag.