Skip to content

Commit

Permalink
Merge pull request #35 from JAK0TA/feat/new-focus-point-function
Browse files Browse the repository at this point in the history
feat: add new function to get focus point by file reference
  • Loading branch information
tlueder authored May 30, 2023
2 parents e399672 + 7bc66ba commit 01df67a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Classes/Utility/FocusPointUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

use TYPO3\CMS\Core\Imaging\ImageManipulation\CropVariantCollection;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Resource\FileInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class FocusPointUtility {
Expand Down Expand Up @@ -43,4 +44,12 @@ public static function getFocusPoint(string $croppingConfiguration, string $type

return self::calculateFocusPoint($type, $xCrop, $yCrop, $height, $width);
}

public static function getFocusPointFromFile(FileInterface $fileObject, string $type, string $cropVariant = 'default'): float {
if (!$fileObject->hasProperty('crop') || empty($fileObject->getProperty('crop'))) {
return 0.0;
}

return self::getFocusPoint($fileObject->getProperty('crop'), $type, $cropVariant);
}
}

0 comments on commit 01df67a

Please sign in to comment.