/** * Returns important meta data for the given object implementing ImageInterface. * * Will return an array with the following keys: * * "originalImageResourceUri": Uri for the original resource * "previewImageResourceUri": Uri for a preview image with reduced size * "originalDimensions": Dimensions for the original image (width, height, aspectRatio) * "previewDimensions": Dimensions for the preview image (width, height) * "object": object properties like the __identity and __type of the object * * @param ImageInterface $image The image to retrieve meta data for * @return array */ protected function getImageInterfacePreviewData(ImageInterface $image) { // TODO: Now that we try to support all ImageInterface implementations we should use a strategy here to get the image properties for custom implementations if ($image instanceof ImageVariant) { $imageProperties = $this->getImageVariantPreviewData($image); } else { $imageProperties = $this->getImagePreviewData($image); } $imageProperties['object'] = $this->imageInterfaceArrayPresenter->convertFrom($image, 'string'); return $imageProperties; }
/** * Convert an object from \TYPO3\Media\Domain\Model\ImageInterface to a json representation. * * @param ImageInterface $source * @param string $targetType must be 'string' * @param array $convertedChildProperties * @param PropertyMappingConfigurationInterface $configuration * @return string The converted ImageInterface */ public function convertFrom($source, $targetType, array $convertedChildProperties = array(), PropertyMappingConfigurationInterface $configuration = null) { $data = parent::convertFrom($source, 'array', $convertedChildProperties, $configuration); return json_encode($data); }