Shadab
Well-known member
The Idea:
Typically BBCodes have only one representation (or view, if you'd like to call it that). Like img, media=youtube and attach bbcodes are replaced by the appropriate embedded image, youtube video and attachment respectively; when viewed in a discussion normally.
What we need is an alternate representation of such rich bbcodes when they are displayed in locations other than the original post: like in a quoted post, global news feed, the Posting & Recent Activity tabs in our own profile, search results, and in the advanced thread preview. So...
Implementation:
Storing the secondary view just like how the (current) primary view is stored. And slightly changing the API of the BBCode parser to include an optional argument for returning the secondary view. Here's what I've got in mind (& all the source code is just hypothetical
):
References:
Threads which got me thinking:
Typically BBCodes have only one representation (or view, if you'd like to call it that). Like img, media=youtube and attach bbcodes are replaced by the appropriate embedded image, youtube video and attachment respectively; when viewed in a discussion normally.
What we need is an alternate representation of such rich bbcodes when they are displayed in locations other than the original post: like in a quoted post, global news feed, the Posting & Recent Activity tabs in our own profile, search results, and in the advanced thread preview. So...
- An image would be represented by a plain link to the image.
e.g.: View Image or http://foo.com/bar.png
- A youtube video be represented by a link to the actual youtube video page.
e.g.: http://www.youtube.com/watch?v=1HtCquBppTc
- An attachment be replaced by a link to the attachment. (already implemented for quoted posts)
e.g.: View Attachment <attachment_id>
Implementation:
Storing the secondary view just like how the (current) primary view is stored. And slightly changing the API of the BBCode parser to include an optional argument for returning the secondary view. Here's what I've got in mind (& all the source code is just hypothetical

PHP:
$content = $parser->parseBbcode($rawContent, $fooBar, XF_BBCode::ALTERNATE_VIEW);
References:
Threads which got me thinking:
- Posting image without writing text (posts #1 - #4)
- Embedded video limit (Thanks to the mod who split it
).
Upvote
15