protected function BaseDataProvider::getSizes in Gutenberg 8
Same name and namespace in other branches
- 8.2 src/DataProvider/BaseDataProvider.php \Drupal\gutenberg\DataProvider\BaseDataProvider::getSizes()
Get sizes of image styles for the source.
Parameters
\Drupal\gutenberg\DataProvider\string $source_url: The source URL.
\Drupal\gutenberg\DataProvider\string $uri: The URI.
Return value
array The sizes of the image styles.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
2 calls to BaseDataProvider::getSizes()
- FileEntityDataProvider::getData in src/
DataProvider/ FileEntityDataProvider.php - Returns array data.
- MediaEntityDataProvider::getData in src/
DataProvider/ MediaEntityDataProvider.php - Returns array data.
File
- src/
DataProvider/ BaseDataProvider.php, line 84
Class
- BaseDataProvider
- Provides base abstraction for entity data providers.
Namespace
Drupal\gutenberg\DataProviderCode
protected function getSizes(string $source_url, string $uri) {
$styles = $this->entityTypeManager
->getStorage('image_style')
->loadMultiple();
$sizes = [
'full' => [
'source_url' => $source_url,
],
];
foreach ($styles as $style) {
/** @var \Drupal\image\Entity\ImageStyle $style */
$sizes[$style
->getName()] = [
'source_url' => file_url_transform_relative($style
->buildUrl($uri)),
];
}
return $sizes;
}