public function toDOMElement()

in src/Facebook/InstantArticles/Elements/Video.php [456:512]


    public function toDOMElement($document = null)
    {
        if (!$document) {
            $document = new \DOMDocument();
        }

        $element = $document->createElement('figure');

        // Presentation
        if ($this->presentation) {
            $element->setAttribute('data-mode', $this->presentation);
        }

        // Poster frame / Image placeholder
        if ($this->imageURL) {
            $imageElement = $document->createElement('img');
            $imageElement->setAttribute('src', $this->imageURL);
            $element->appendChild($imageElement);
        }

        if ($this->isFeedCover) {
            $element->setAttribute('class', 'fb-feed-cover');
        }

        // URL markup required
        if ($this->url) {
            $videoElement = $document->createElement('video');
            if (!$this->isAutoplay) {
                $videoElement->setAttribute('data-fb-disable-autoplay', 'data-fb-disable-autoplay');
            }
            if ($this->isControlsShown) {
                $videoElement->setAttribute('controls', 'controls');
            }
            $sourceElement = $document->createElement('source');
            $sourceElement->setAttribute('src', $this->url);
            if ($this->contentType) {
                $sourceElement->setAttribute('type', $this->contentType);
            }
            $videoElement->appendChild($sourceElement);
            $element->appendChild($videoElement);
        }

        // Caption markup optional
        Element::appendChild($element, $this->caption, $document);

        // Geotag markup optional
        Element::appendChild($element, $this->geoTag, $document);

        // Attribution Citation
        if ($this->attribution) {
            $attributionElement = $document->createElement('cite');
            $attributionElement->appendChild($document->createTextNode($this->attribution));
            $element->appendChild($attributionElement);
        }

        return $element;
    }