public function QuickEditImageController::getInfo in Drupal 9
Same name and namespace in other branches
- 8 core/modules/image/src/Controller/QuickEditImageController.php \Drupal\image\Controller\QuickEditImageController::getInfo()
Returns JSON representing an image field's metadata.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity of which an image field is being rendered.
string $field_name: The name of the (image) field that is being rendered
string $langcode: The language code of the field that is being rendered.
string $view_mode_id: The view mode of the field that is being rendered.
Return value
\Drupal\Core\Cache\CacheableJsonResponse The JSON response.
1 string reference to 'QuickEditImageController::getInfo'
- image.routing.yml in core/
modules/ image/ image.routing.yml - core/modules/image/image.routing.yml
File
- core/
modules/ image/ src/ Controller/ QuickEditImageController.php, line 187
Class
- QuickEditImageController
- Returns responses for our image routes.
Namespace
Drupal\image\ControllerCode
public function getInfo(EntityInterface $entity, $field_name, $langcode, $view_mode_id) {
$field = $this
->getField($entity, $field_name, $langcode);
$settings = $field
->getFieldDefinition()
->getSettings();
$info = [
'alt' => $field->alt,
'title' => $field->title,
'alt_field' => $settings['alt_field'],
'title_field' => $settings['title_field'],
'alt_field_required' => $settings['alt_field_required'],
'title_field_required' => $settings['title_field_required'],
];
$response = new CacheableJsonResponse($info);
$response
->addCacheableDependency($entity);
return $response;
}