Problem/Motivation

The matcher has options to display image size and a thumbnail, there are two problems with that. It calls isValid() on every file, even if those options are not enabled and even if they are not images.

For example, that might result in calling isValid() on videos stored on S3, or PDF's or so, resulting in errors/warnings and slow responses.

Proposed resolution

Make two changes:

a) Only call isValid() and do the image factory thing if either of the two options is really enabled.

b) And also only call it if the file extension is supported by the configured toolkit (\Drupal\Core\ImageToolkit\ImageToolkitInterface::getSupportedExtensions(), check how \Drupal\image\Plugin\Field\FieldWidget\ImageWidget::formElement() does that.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#2 3018705-2.patch2.32 KBarpad.rozsa
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir created an issue. See original summary.

arpad.rozsa’s picture

Status: Active » Needs review
FileSize
2.32 KB

Done the two changes as you suggested.

Berdir’s picture

Status: Needs review » Reviewed & tested by the community

Looks good, hard to test without having unit tests and mocking for it.

  • anon committed 3b5b286 on 8.x-5.x authored by arpad.rozsa
    Issue #3018705 by arpad.rozsa: FileMatcher checks image information if...
anon’s picture

Status: Reviewed & tested by the community » Fixed

Works perfect. Thanks for patch.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.