Skip to content
Snippets Groups Projects

fix the issue

1 file
+ 5
4
Compare changes
  • Side-by-side
  • Inline
@@ -21,8 +21,9 @@ protected function computeValue() {
$config = \Drupal::config('jsonapi_image_styles.settings');
$styles = [];
$entity = $this->getEntity();
$uri = ($entity instanceof File && substr($entity->getMimeType(), 0, 5) === 'image') ? $entity->getFileUri() : FALSE;
$mimeType = $entity instanceof File ? $entity->getMimeType() : null;
$uri = ($mimeType && mb_substr($mimeType, 0, 5) === 'image') ? $entity->getFileUri() : FALSE;
if ($uri) {
$defined_styles = $config->get('image_styles') ?? [];
if (!empty(array_filter($defined_styles))) {
@@ -33,7 +34,7 @@ protected function computeValue() {
else {
$styles = ImageStyle::loadMultiple();
}
$uris = [];
foreach ($styles as $name => $style) {
if ($style instanceof ImageStyle) {
@@ -42,6 +43,6 @@ protected function computeValue() {
}
$this->list[] = $this->createItem(0, $uris);
}
}
}
}
Loading