public function ImageWidgetCropManager::loadImageStyleByCrop in Image Widget Crop 8
Same name and namespace in other branches
- 8.2 src/ImageWidgetCropManager.php \Drupal\image_widget_crop\ImageWidgetCropManager::loadImageStyleByCrop()
Load all crop using the ImageStyles.
Parameters
array $image_styles: All ImageStyle for this current CROP.
CropType $crop_type: The entity CropType.
string $file_uri: Uri of uploded file.
Return value
array All crop used this ImageStyle.
3 calls to ImageWidgetCropManager::loadImageStyleByCrop()
- ImageWidgetCropManager::buildCropToEntity in src/
ImageWidgetCropManager.php - Fetch all fields FileField and use "image_crop" element on an entity.
- ImageWidgetCropManager::buildCropToForm in src/
ImageWidgetCropManager.php - Fetch all form elements using image_crop element.
- ImageWidgetCropManager::updateCrop in src/
ImageWidgetCropManager.php - Update old crop with new properties choose in UI.
File
- src/
ImageWidgetCropManager.php, line 351
Class
- ImageWidgetCropManager
- ImageWidgetCropManager calculation class.
Namespace
Drupal\image_widget_cropCode
public function loadImageStyleByCrop(array $image_styles, CropType $crop_type, $file_uri) {
$crops = [];
/** @var \Drupal\image\Entity\ImageStyle $image_style */
foreach ($image_styles as $image_style) {
/** @var \Drupal\crop\Entity\Crop $crop */
$crop = Crop::findCrop($file_uri, $crop_type
->id());
if (!empty($crop)) {
$crops[$image_style
->id()] = $crop;
}
}
return $crops;
}