- Issue created by @isaacrc
- last update
7 months ago 15 pass - Issue was unassigned.
- Status changed to Needs review
7 months ago 2:37pm 11 April 2024
In the hook_ENTITY_TYPE_insert() in the image_resize.module file:
/**
* Implements hook_ENTITY_TYPE_insert().
*/
function image_resize_file_insert(FileInterface $file) {
$config = \Drupal::config('image_resize.settings');
if (in_array($file->getMimeType(), $config->get('mimetypes'), TRUE)) {
if ($config->get('min_filesize') && $file->getSize() > $config->get('min_filesize')) {
$queue = \Drupal::service('queue')->get('image_resize');
$queue->createItem($file->id());
}
}
}
$file->getSize() returns the size in bytes however, the configuration setting retrieved by $config->get('min_filesize') specifies file sizes in user-friendly units (KB, MB etc), as indicated in the configuration description:
'#description' => $this->t('Only attempt to resize images above the given file size. Enter a value like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes) in order to restrict the allowed file size.'),
This mismatch causes improper handling of the file size comparison, leading to incorrect skipped resizing operations.
Convert the value from the config to bytes using Bytes::toNumber for the comparison as done elsewhere in the module.
Provide a MR
none
none
none
Needs review
1.0
Code