/** * {@inheritdoc} */ protected function doTransform(MediaInterface $media) { parent::doTransform($media); if ($media->getBinaryContent() instanceof UploadedFile) { $fileName = $media->getBinaryContent()->getClientOriginalName(); } elseif ($media->getBinaryContent() instanceof File) { $fileName = $media->getBinaryContent()->getFilename(); } else { // Should not happen, FileProvider should throw an exception in that case return; } if (!in_array(strtolower(pathinfo($fileName, PATHINFO_EXTENSION)), $this->allowedExtensions) || !in_array($media->getBinaryContent()->getMimeType(), $this->allowedMimeTypes)) { return; } try { $image = $this->imagineAdapter->open($media->getBinaryContent()->getPathname()); } catch (\RuntimeException $e) { $media->setProviderStatus(MediaInterface::STATUS_ERROR); return; } $size = $image->getSize(); $media->setWidth($size->getWidth()); $media->setHeight($size->getHeight()); $media->setProviderStatus(MediaInterface::STATUS_OK); }
/** * {@inheritdoc} */ protected function doTransform(MediaInterface $media) { parent::doTransform($media); if ($media->getBinaryContent()) { $image = $this->imagineAdapter->open($media->getBinaryContent()->getPathname()); $size = $image->getSize(); $media->setWidth($size->getWidth()); $media->setHeight($size->getHeight()); $media->setProviderStatus(MediaInterface::STATUS_OK); } }
/** * {@inheritdoc} */ protected function doTransform(MediaInterface $media) { parent::doTransform($media); if (!is_object($media->getBinaryContent()) && !$media->getBinaryContent()) { return; } try { $image = $this->imagineAdapter->open($media->getBinaryContent()->getPathname()); } catch (\RuntimeException $e) { $media->setProviderStatus(MediaInterface::STATUS_ERROR); return; } $size = $image->getSize(); $media->setWidth($size->getWidth()); $media->setHeight($size->getHeight()); $media->setProviderStatus(MediaInterface::STATUS_OK); }
/** * {@inheritdoc} */ protected function doTransform(MediaInterface $media) { parent::doTransform($media); // if ($media->getBinaryContent() instanceof UploadedFile) { // $fileName = $media->getBinaryContent()->getClientOriginalName(); // } elseif ($media->getBinaryContent() instanceof File) { // $fileName = $media->getBinaryContent()->getFilename(); // } else { // // Should not happen, FileProvider should throw an exception in that case // return; // } // if (!in_array(strtolower(pathinfo($fileName, PATHINFO_EXTENSION)), $this->allowedExtensions) // || !in_array($media->getBinaryContent()->getClientMimeType(), $this->allowedMimeTypes)) { // die(var_dump($fileName, $this->allowedExtensions, $this->allowedMimeTypes)); // return; // } // // this is the name used to store the file // if (!$media->getProviderReference() || // $media->getProviderReference() === MediaInterface::MISSING_BINARY_REFERENCE // ) { // $media->setProviderReference($this->generateReferenceName($media)); // } if ($media->getBinaryContent()) { $media->setContentType($media->getBinaryContent()->getClientMimeType()); $media->setSize($media->getBinaryContent()->getSize()); } //$media->setProviderReference($media->getName()); //$media->setContentType($media->getBinaryContent()->getClientMimeType()); //die(var_dump($media)); }
protected function doTransform(MediaInterface $media) { parent::doTransform($media); $media->setProviderStatus(MediaInterface::STATUS_ENCODING); }
/** * {@inheritdoc} */ protected function doTransform(MediaInterface $media) { parent::doTransform($media); if ($media->getBinaryContent() instanceof UploadedFile) { $fileName = $media->getBinaryContent()->getClientOriginalName(); } elseif ($media->getBinaryContent() instanceof File) { $fileName = $media->getBinaryContent()->getFilename(); } else { // Should not happen, FileProvider should throw an exception in that case return; } if (!in_array(strtolower(pathinfo($fileName, PATHINFO_EXTENSION)), $this->allowedExtensions) || !in_array($media->getBinaryContent()->getMimeType(), $this->allowedMimeTypes)) { return; } try { /* $ffprobe = \FFMpeg\FFProbe::create(); */ $ffprobe = $this->getFFProbe(); $dimension = $ffprobe->streams($media->getBinaryContent()->getPathname())->videos()->first()->getDimensions(); $media->setWidth($dimension->getWidth()); $media->setHeight($dimension->getHeight()); $media->setProviderStatus(MediaInterface::STATUS_OK); } catch (\RuntimeException $e) { $media->setProviderStatus(MediaInterface::STATUS_ERROR); } }