5 use Drupal\Core\Entity\ContentEntityInterface;
6 use Drupal\image\ImageStyleInterface;
9 * Provides an interface defining the crop entity.
11 interface CropInterface extends ContentEntityInterface {
14 * Gets position of crop's center.
17 * Array with two keys (x, y) and center coordinates as values.
19 public function position();
22 * Sets position of crop's center.
25 * X coordinate of the crop's center.
27 * Y coordinate of the crop's center.
29 * @return \Drupal\crop\CropInterface
30 * Crop object this is being called on.
32 public function setPosition($x, $y);
38 * Array with two keys (width, height) each side dimensions as values.
40 public function size();
50 * @return \Drupal\crop\CropInterface
51 * Crop object this is being called on.
53 public function setSize($width, $height);
56 * Gets crop anchor (top-left corner of crop area).
59 * Array with two keys (x, y) and anchor coordinates as values.
61 public function anchor();
64 * Gets entity provider for the crop.
66 * @return \Drupal\crop\EntityProviderInterface
69 * @throws \Drupal\crop\EntityProviderNotFoundException
70 * Thrown if entity provider not found.
72 public function provider();
75 * Checks whether crop exists for an image.
78 * URI of image to check for.
80 * (Optional) Type of crop. Function will check across all available types
84 * Boolean TRUE if crop exists and FALSE if not.
86 public static function cropExists($uri, $type = NULL);
89 * Loads crop based on image URI and crop type.
96 * @return \Drupal\crop\CropInterface|null
97 * Crop entity or NULL if crop doesn't exist.
99 public static function findCrop($uri, $type);
102 * Retrieve crop from given image style.
106 * @param \Drupal\image\ImageStyleInterface $image_style
109 * @return \Drupal\crop\CropInterface|null
110 * Crop entity used by effect 'crop_crop' or NULL if crop doesn't exist.
112 public static function getCropFromImageStyle($uri, ImageStyleInterface $image_style);