/** * Render core video thumbnail HTML * @requestParam MediaTransformOutput thumb * @requestParam array options - See ThumbnailHelper class for more detail * @responseParam string width * @responseParam string height * @responseParam string linkHref * @responseParam array linkClasses * @responseParam string linkId * @responseParam array linkAttrs * @responseParam string imgSrc * @responseParam string mediaKey * @responseParam string mediaName * @responseParam array imgClass * @responseParam array extraImgAttrs * @responseParam string dataSrc - data-src attribute for image lazy loading * @responseParam string duration (HH:MM:SS) * @responseParam array durationISO * @responseParam string mediaType - 'image' | 'video' */ public function video() { wfProfileIn(__METHOD__); $thumb = $this->getVal('thumb'); $options = $this->getVal('options', []); ThumbnailHelper::setVideoLinkClasses($this, $thumb, $options); ThumbnailHelper::setVideoLinkAttribs($this, $thumb, $options); ThumbnailHelper::setVideoImgAttribs($this, $thumb, $options); ThumbnailHelper::setExtraImgAttribs($this, $options); ThumbnailHelper::setExtraLinkAttribs($this, $options); // Set duration // The file is not always an instance of a class with magic getters implemented. see VID-1753 $file = $thumb->file; if (is_callable([$file, 'getMetadataDuration'])) { $duration = $file->getMetadataDuration(); } else { $duration = null; } $this->response->setVal('duration', WikiaFileHelper::formatDuration($duration)); $this->response->setVal('mediaType', 'video'); $lazyLoaded = ThumbnailHelper::setLazyLoad($this, $options); if (!$lazyLoaded) { // Only add RDF metadata when the thumb is not lazy loaded $this->response->setVal('rdf', true); if (!empty($duration)) { $this->response->setVal('durationISO', WikiaFileHelper::formatDurationISO8601($duration)); } } wfProfileOut(__METHOD__); }