function QuickEditImageController::getInfo
Same name in this branch
- 9 core/modules/quickedit/src/Controller/QuickEditImageController.php \Drupal\quickedit\Controller\QuickEditImageController::getInfo()
Same name in other branches
- 8.9.x 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.
File
-
core/
modules/ image/ src/ Controller/ QuickEditImageController.php, line 188
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.