/** * When retrieving the height or width for a media file * a possible cropping needs to be taken into account. * * @param FileInterface $fileObject * @param string $dimensionalProperty 'width' or 'height' * @return int */ protected function getCroppedProperty(FileInterface $fileObject, $dimensionalProperty) { if (!$fileObject->hasProperty('crop') || empty($fileObject->getProperty('crop'))) { return $fileObject->getProperty($dimensionalProperty); } $croppingConfiguration = json_decode($fileObject->getProperty('crop'), true); return (int) $croppingConfiguration[$dimensionalProperty]; }
/** * When retrieving the width for a media file * a possible cropping needs to be taken into account. * * @param FileInterface $fileObject * @return int */ protected function getCroppedWidth(FileInterface $fileObject) { if (!$fileObject->hasProperty('crop') || empty($fileObject->getProperty('crop'))) { return $fileObject->getProperty('width'); } $croppingConfiguration = json_decode($fileObject->getProperty('crop'), true); return (int) $croppingConfiguration['width']; }