Trying to display post in front (attachment/image)

Ghostaunt

Active member
hello !

I'm trying to display post in the front of my website. It work, but not for attachments.
Image are not displayed, and I have "view attachment x"

Here a screen to the issue
0119228f85.png


And on my forum I have the image.

My code :
Code:
public function getTopic($topic_id)
    {
        $topic = XenForo_Model::create('XenForo_Model_Thread')->getThreadById($topic_id, array('join' => XenForo_Model_Thread::FETCH_FIRSTPOST));
        $formatter = XenForo_BbCode_Formatter_Base::create();
        $parser = new XenForo_BbCode_Parser($formatter);
        $topic['message_html'] = $parser->render($topic['message']);

        return $topic;
    }

I've tried to find a solution, but found nothing...
Thanks for your help !
 
Yep, but I think it's in the XenForo_ViewPublic_Thread_View model. I think i have to do the same thing as here but I don't know how
Code:
class XenForo_ViewPublic_Thread_View extends XenForo_ViewPublic_Base
{
    public function renderHtml()
    {
        $bbCodeParser = XenForo_BbCode_Parser::create(XenForo_BbCode_Formatter_Base::create('Base', array('view' => $this)));
        $bbCodeOptions = array(
            'states' => array(
                'viewAttachments' => $this->_params['canViewAttachments']
            ),
            'contentType' => 'post',
            'contentIdKey' => 'post_id'
        );
        XenForo_ViewPublic_Helper_Message::bbCodeWrapMessages($this->_params['posts'], $bbCodeParser, $bbCodeOptions);

        if (!empty($this->_params['canQuickReply']))
        {
            $draft = isset($this->_params['thread']['draft_message']) ? $this->_params['thread']['draft_message'] : '';

            $this->_params['qrEditor'] = XenForo_ViewPublic_Helper_Editor::getQuickReplyEditor(
                $this, 'message', $draft,
                array(
                    'autoSaveUrl' => XenForo_Link::buildPublicLink('threads/save-draft', $this->_params['thread']),
                    'json' => array('placeholder' => 'reply_placeholder')
                )
            );
        }
    }
}
 
Last edited:
  • Like
Reactions: LPH
Top Bottom