- Issue created by @idiaz.roncero
I am somewhat confused by what it looks like a missing implementation.
I can see the module is using the tempStore to process and store the existing crops for a given entity, using its view modes.
Now, I can see the ContextualImageCropWidget
makes use of this info to actually do something (hiding the other crops:
if ($context = $this->request->query->all('crop-context')) {
// Limit crop types to crop type defined in context.
$element['#crop_list'] = array_intersect($element['#crop_list'], $context);
$element['#warn_multiple_usages'] = FALSE;
$element['#show_crop_area'] = TRUE;
// Reset context again.
$this->privateTempStore->delete(MediaAjaxForm::CROP_CONTEXT);
}
...but I can't find a similar logic for the ContextualImageCropMediaLibraryWidget
.
I can see it is forwarding the crop-context
to the edit-form-ajax
$media_item->toLink('edit / crop', 'edit-form-ajax', [
'query' => [
'crop-context' => $crop_types,
'element-parents' => implode('/', $element_parents),
'file-uri' => $file->getFileUri(),
'image-style' => $image_style->id(),
],
...but then the edit-form-ajax
, which uses MediaAjaxForm
, seems to be doing nothing with this info.
The only uses for the crop_context
on theMediaAjaxForm
are on the construct
method, but this info is not used anywhere else. So, the module seems to be doing nothing with this info, other than setting it.
public function __construct(EntityRepositoryInterface $entity_repository, PrivateTempStoreFactory $private_temp_store_factory, RequestStack $request_stack, EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL, TimeInterface $time = NULL) {
parent::__construct($entity_repository, $entity_type_bundle_info, $time);
$this->request = $request_stack->getCurrentRequest();
$this->privateTempStore = $private_temp_store_factory->get('contextual_image_widget_crop');
$this->privateTempStore->delete(self::CROP_CONTEXT);
if ($context = $this->request->query->all('crop-context')) {
// Store crop context in temp store.
$this->privateTempStore->set(self::CROP_CONTEXT, $context);
}
}
Am I correct? Or am I missing something?
Active
1.0
Code