/**
  * Updates the dimension (height, width) and duration metadata of the specified media file in FAL
  *
  * @param  \TYPO3\CMS\Core\Resource\File $file  FAL record
  * @return void
  */
 protected function setFileMetadata(\TYPO3\CMS\Core\Resource\File $file)
 {
     // Get file for local processing
     $localFile = $file->getForLocalProcessing(FALSE);
     // Fetch media information
     $parser = new \PHPVideoToolkit\MediaParser();
     $fileInfo = $parser->getFileInformation($localFile);
     // Collect relevant media information
     $fileMetadata = array();
     $fileMetadata['duration'] = $fileInfo['duration']->total_seconds;
     if (isset($fileInfo['video']['dimensions'])) {
         $fileMetadata['height'] = $fileInfo['video']['dimensions']['height'];
         $fileMetadata['width'] = $fileInfo['video']['dimensions']['width'];
     }
     // Update metadata of FAL record
     if (!empty($fileMetadata)) {
         $file->_updateMetaDataProperties($fileMetadata);
         $this->metaDataRepository->update($file->getUid(), $fileMetadata);
     }
 }
Example #2
0
 /**
  * Since the core desperately needs image sizes in metadata table put them there
  * This should be called after every "content" update and "record" creation
  *
  * @param File $fileObject
  */
 protected function extractRequiredMetaData(File $fileObject)
 {
     // since the core desperately needs image sizes in metadata table do this manually
     // prevent doing this for remote storages, remote storages must provide the data with extractors
     if ($fileObject->getType() == File::FILETYPE_IMAGE && $this->storage->getDriverType() === 'Local') {
         $rawFileLocation = $fileObject->getForLocalProcessing(FALSE);
         $imageInfo = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Type\\File\\ImageInfo', $rawFileLocation);
         $metaData = array('width' => $imageInfo->getWidth(), 'height' => $imageInfo->getHeight());
         $this->getMetaDataRepository()->update($fileObject->getUid(), $metaData);
         $fileObject->_updateMetaDataProperties($metaData);
     }
 }
Example #3
0
 /**
  * Since the core desperately needs image sizes in metadata table put them there
  * This should be called after every "content" update and "record" creation
  *
  * @param File $fileObject
  */
 protected function extractRequiredMetaData(File $fileObject)
 {
     // since the core desperately needs image sizes in metadata table do this manually
     // prevent doing this for remote storages, remote storages must provide the data with extractors
     if ($fileObject->getType() == File::FILETYPE_IMAGE && $this->storage->getDriverType() === 'Local') {
         $rawFileLocation = $fileObject->getForLocalProcessing(FALSE);
         $metaData = array();
         list($metaData['width'], $metaData['height']) = getimagesize($rawFileLocation);
         $this->getMetaDataRepository()->update($fileObject->getUid(), $metaData);
         $fileObject->_updateMetaDataProperties($metaData);
     }
 }