} } // Note that we intentionally do not use:
// - \Drupal\Core\Cache\CacheableResponse because caching it on the server
// side is wasteful, hence there is no need for cacheability metadata.
// - \Drupal\Core\Render\HtmlResponse because there is no need for
// attachments nor cacheability metadata.
return (new JsonResponse($response, 200
)) // Do not allow any intermediary to cache the response, only the end user.
->
setPrivate() // Allow the end user to cache it for up to 5 minutes.
->
setMaxAge(300
);
} /**
* Additional access check for ::isMediaImage().
*
* This grants access if media embed filter is enabled on the filter format
* and user has access to view the media entity.
*
* Note that access to the filter format is not checked here because the route
* is configured to check entity access to the filter format.
*
* @param \Drupal\editor\Entity\Editor $editor
* The text editor.
*
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
*
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
* Thrown when no media UUID is provided.
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* Thrown when no media with the provided UUID exists.
*/