media_objects() html()

Media objects (an image beside a heading and text) nested by parent_id, e.g. comment threads.

html()->media_objects($data = [], $extra = [])

Options

OptionMeaning
$dataId => ['img', 'alt', 'link', 'head', 'body' (HTML), 'date', 'parent_id'].
class, idClasses; id.

Example

64x64

Comment 1 2026-11-14 18:20:00

Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo.

Comment 2

Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo.

A reply

Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo.

A reply to the reply.

Code

$img = 'data:image/svg+xml,' . rawurlencode('<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64"><rect width="64" height="64" fill="#999"/></svg>');
$body = 'Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo.';
return html()->media_objects([
    11 => ['link' => '#comment-11', 'img' => $img, 'alt' => '64x64', 'head' => 'Comment 1', 'body' => $body, 'date' => '2026-11-14 18:20'],
    22 => ['link' => '#comment-22', 'img' => $img, 'head' => 'Comment 2', 'body' => $body],
    33 => ['link' => '#comment-33', 'img' => $img, 'head' => 'A reply', 'body' => $body, 'parent_id' => 22],
    44 => ['img' => $img, 'body' => 'A reply to the reply.', 'parent_id' => 33],
]);

Bootstrap 3 and 5

Bootstrap 3 media; Bootstrap 5 has no media object: d-flex + flex-shrink-0 markup.

See also: html/tree, html/thumbnails