Commit 3b5b286c authored by arpad.rozsa's avatar arpad.rozsa Committed by anon

Issue #3018705 by arpad.rozsa: FileMatcher checks image information if not...

Issue #3018705 by arpad.rozsa: FileMatcher checks image information if not needed and for non-image files
parent 1ff6c1cb
......@@ -190,22 +190,30 @@ class FileMatcher extends EntityMatcher {
/** @var \Drupal\file\FileInterface $entity */
$file = $entity->getFileUri();
/** @var \Drupal\Core\Image\ImageInterface $image */
$image = \Drupal::service('image.factory')->get($file);
if ($image->isValid()) {
if ($this->configuration['images']['show_dimensions']) {
$description_array[] = $image->getWidth() . 'x' . $image->getHeight() . 'px';
}
if ($this->configuration['images']['show_thumbnail'] && $this->moduleHandler->moduleExists('image')) {
$image_element = [
'#weight' => -10,
'#theme' => 'image_style',
'#style_name' => $this->configuration['images']['thumbnail_image_style'],
'#uri' => $entity->getFileUri(),
];
$description_array[] = (string) \Drupal::service('renderer')->render($image_element);
if ($this->configuration['images']['show_dimensions'] || $this->configuration['images']['show_thumbnail']) {
$image_factory = \Drupal::service('image.factory');
$supported_extensions = $image_factory->getSupportedExtensions();
// Check if the file extension is supported by the image toolkit.
if (empty(file_validate_extensions($entity, implode(' ', $supported_extensions)))) {
/** @var \Drupal\Core\Image\ImageInterface $image */
$image = $image_factory->get($file);
if ($image->isValid()) {
if ($this->configuration['images']['show_dimensions']) {
$description_array[] = $image->getWidth() . 'x' . $image->getHeight() . 'px';
}
if ($this->configuration['images']['show_thumbnail'] && $this->moduleHandler->moduleExists('image')) {
$image_element = [
'#weight' => -10,
'#theme' => 'image_style',
'#style_name' => $this->configuration['images']['thumbnail_image_style'],
'#uri' => $entity->getFileUri(),
];
$description_array[] = (string) \Drupal::service('renderer')->render($image_element);
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment