BBCode::doYoutube PHP Method

doYoutube() public method

Perform formatting against a string for the youtube tag
public doYoutube ( 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 doYoutube($bbcode, $action, $name, $default, $params, $content)
    {
        if ($action == Nbbc::BBCODE_CHECK) {
            return true;
        }
        $videoId = is_string($default) ? $default : $bbcode->unHTMLEncode(strip_tags($content));
        return "<div class=\"Video P\"><iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/{$videoId}\" frameborder=\"0\" allowfullscreen></iframe></div>";
    }