You are here

function hook_gutenberg_media_search_query_alter in Gutenberg 8.2

Same name and namespace in other branches
  1. 8 gutenberg.api.php \hook_gutenberg_media_search_query_alter()

Perform alterations to a gutenberg's media (file entity) search query.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The request.

string $type: MIME type search string.

string $search: Filename search string.

\Drupal\Core\Entity\Query\Sql\Query $query: Entity query object.

1 invocation of hook_gutenberg_media_search_query_alter()
MediaService::search in src/Service/MediaService.php
Search for file entities.

File

./gutenberg.api.php, line 28
Documentation for Gutenberg module APIs.

Code

function hook_gutenberg_media_search_query_alter(Request $request, string $type, string $search, Query $query) {
  if ($type === 'image') {
    $query
      ->condition('uri', 'public://avatars/%', 'NOT LIKE');
  }

  // Load at most 100 media entities at a time.
  $query
    ->range(0, 100);
}