1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.1 Remove [IMG] & [media] BBCodes from quoted post

Discussion in 'XenForo Questions and Support' started by DBA, Jan 23, 2012.

  1. DBA

    DBA Well-Known Member

    How do I remove the and [media] bbcode from quoted posts? For example I'll have a member create a ride report with 20 images per post. Then the next guy comes along and quotes him only to add a simple "sweet report". So you basically have to scroll through all 20 images to see the "sweet report" message.

    Here's what I'd done in vB.
    maszd and gordy like this.
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Definitely requires code changes. This is the relevant code in XF:


    This can be extended with the addon system, or you can modify the file directly.
  3. craigiri

    craigiri Well-Known Member

    This would be a great little mod or add-on!

    It's amazing that it's not requested more often....
    maszd likes this.
  4. craigiri

    craigiri Well-Known Member

    To be more clear, it's only external images and media that get quoted - uploads already work correctly in terms of not being rendered in the quoted material....
  5. DBA

    DBA Well-Known Member

    That is correct. I wish that external media (IMG and media tags) had the same behavior as attach tags when quoted.
  6. Phillip

    Phillip Active Member

    Did you ever find a solution to this? I'd like to have smilies not appear in quoted messages.
  7. craigiri

    craigiri Well-Known Member

    Nothing I know of yet!
  8. DBA

    DBA Well-Known Member

    No I haven't and I still find it to be very annoying. :mad:
  9. KidCactus

    KidCactus Member

    Has anyone gotten something like this to work yet?

    Could this be used in some way, found in String.php?
        * Strips BB code from a string
        * @param string $string
        * @param boolean $stripQuote If true, contents from within quote tags are stripped
        * @return string
        public static function bbCodeStrip($string, $stripQuote = false)
            /*$formatter = XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_BbCode_Strip', false);
            $parser = new XenForo_BbCode_Parser($formatter);
            return $parser->render($string);*/
            // note: this is extremely primitive!
            if ($stripQuote)
                $string = preg_replace('#\[(quote)[^\]]*\].*\[/\\1\]#siU', ' ', $string);
            // replaces unviewable tags with a text representation
            $string = preg_replace('#\[(attach|media|img)[^\]]*\].*\[/\\1\]#siU', '[\\1]', $string);
            while ($string != ($newString = preg_replace('#\[([a-z0-9]+)(=[^\]]*)?\](.*)\[/\1\]#siU', '\3', $string)))
                $string = $newString;
            $string = str_replace('[*]', '', $string);
            return $string;
  10. DBA

    DBA Well-Known Member

    If you figure it out please let me know.
  11. gordy

    gordy Well-Known Member

    It is very annoying.

    For an interim solution, maybe rephrase "reply" to "quote". Conditioning members to use the quick reply. I never understood why it's called 'reply' when it quotes as well.
    Digital Doctor and Darkimmortal like this.
  12. Luke F

    Luke F Well-Known Member


    Quite misleading really and one of the first things I changed
  13. DBA

    DBA Well-Known Member

    Same here. (y)

    gldtn and gordy like this.
  14. DBA

    DBA Well-Known Member

    Now that I think about it, I'd also added a "Reply to Thread" button at the top that goes to:
    So upon clicking the button it takes you to the quick reply.


    How about changing the current "Reply" phrase to "Quote" and adding a new link called "Reply" that adds the #quickReply anchor to the url?
    gordy likes this.
  15. KidCactus

    KidCactus Member

    I've also changed Reply to Quote, or rather Citera in Swedish, but that still doesn't stop my users from constantly clicking it and re-posting images and media. This gets very annoying, especially when the same Youtube video appears in several posts in a row.

    But that "Strips BB code from a string" thing looks like it's meant to strip exactly what we want, but it also seems it's not implemented as a working option in Xenforo? Any comment on this from the developers?
  16. KidCactus

    KidCactus Member

    Well, replacing this in Post.php:

    . trim(XenForo_Helper_String::stripQuotes($post['message'], $maxQuoteDepth))

    . trim(XenForo_Helper_String::bbCodeStrip($post['message'], $maxQuoteDepth))
    kind of works, but it leaves a [ img ] or [ media ] opening tag in the quoted post, and anything after the closing tag is also removed. o_O And of course, it also breaks the nested quotes removal.
  17. DBA

    DBA Well-Known Member

    The ideal solution would be for it to behave the same as attached/uploaded images, basically turn into a link instead of being embedded.
  18. KidCactus

    KidCactus Member

    That is exactly what I want too.
  19. KidCactus

    KidCactus Member

    Jake Bunce likes this.
  20. DBA

    DBA Well-Known Member

    That's only a band-aid though. Wouldn't the images still be pulled from the server, using resources, they just aren't shown. Plus we do have cases where an image needs to be quoted, however they now wouldn't be visible period. Instead they should be converted to links.

    Would you be interested in offering a few $ to have it developed?

Share This Page