/**
* Perform formatting against a string for the attach tag.
*
* @param Nbbc $bbcode Instance of Nbbc doing the parsing.
* @param int $action Value of one of NBBC's defined constants. Typically, this will be BBCODE_CHECK.
* @param string $name Name of the tag.
* @param string $default Value of the _default parameter, from the $params array.
* @param array $params A standard set parameters related to the tag.
* @param string $content Value between the open and close tags, if any.
* @return string Formatted value.
*/
public function doAttachment($bbcode, $action, $name, $default, $params, $content)
{
$medias = $this->media();
$mediaID = $content;
if (isset($medias[$mediaID])) {
$media = $medias[$mediaID];
$src = htmlspecialchars(Gdn_Upload::url(val('Path', $media)));
$name = htmlspecialchars(val('Name', $media));
if (val('ImageWidth', $media)) {
return "<div class=\"Attachment Image\"><img src=\"{$src}\" alt=\"{$name}\" /></div>";
} else {
return anchor($name, $src, 'Attachment File');
}
}
return anchor(t('Attachment not found.'), '#', 'Attachment NotFound');
}