Images in forum posts?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 anni tempo fa
Can you add images to forum posts? I have tried the BBC code with no luck.
12 anni tempo fa
No, out of the box. You need to add [img] BB code support
12 anni tempo fa
Can you direct me where I could find information on how to do this?
12 anni tempo fa
Look at \src\Libraries\Nop.Core\Html\BBCodeHelper.cs file
12 anni tempo fa
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 */
12 anni tempo fa
Excellent post, that saved me allot of work thank you.
11 anni tempo fa
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)
10 anni tempo fa
I have used this code change up to Nop 3.2 for me.
9 anni tempo fa
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)
9 anni tempo fa
I added the code and also recommendations by thrifty34 and kupala, but code not work yet. Output not convert  to <img>  html tag.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.