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.
- An attachment be replaced by a link to the attachment. (already implemented for quoted posts)
e.g.: View Attachment <attachment_id>
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 ):
$content = $parser->parseBbcode($rawContent, $fooBar, XF_BBCode::ALTERNATE_VIEW);
Threads which got me thinking:
- Posting image without writing text (posts #1 - #4)
- Embedded video limit (Thanks to the mod who split it ).