BBCode::doImage PHP Method

doImage() public method

Perform formatting against a string for the img tag.
public doImage ( Nbbc\BBCode $bbcode, integer $action, string $name, string $default, array $params, string $content ) : boolean | string
$bbcode Nbbc\BBCode Instance of Nbbc doing the parsing.
$action integer Value of one of NBBC's defined constants. Typically, this will be BBCODE_CHECK.
$name string Name of the tag.
$default string Value of the _default parameter, from the $params array.
$params array A standard set parameters related to the tag.
$content string Value between the open and close tags, if any.
return boolean | string Formatted value.
    function doImage($bbcode, $action, $name, $default, $params, $content)
    {
        if ($action == Nbbc::BBCODE_CHECK) {
            return true;
        }
        $content = trim($bbcode->unHtmlEncode(strip_tags($content)));
        if (!$content && $default) {
            $content = $default;
        }
        if ($bbcode->isValidUrl($content, false)) {
            return "<img src=\"" . htmlspecialchars($content) . "\" alt=\"" . htmlspecialchars(basename($content)) . "\" class=\"bbcode_img\" />";
        }
        return htmlspecialchars($params['_tag']) . htmlspecialchars($content) . htmlspecialchars($params['_endtag']);
    }