Skip to content
Snippets Groups Projects
Commit 24c236fd authored by catch's avatar catch
Browse files

Issue #3292350 by O'Briat, KlemenDEV, hswong3i, smustgrave, quietone: Update...

Issue #3292350 by O'Briat, KlemenDEV, hswong3i, smustgrave, quietone: Update the file size in file_validate_image_resolution after resizing

(cherry picked from commit 1a3d72bc)
(cherry picked from commit 2340e939)
parent 98882c4f
No related branches found
No related tags found
8 merge requests!8376Drupal views: adding more granularity to the ‘use ajax’ functionality,!8300Issue #3443586 View area displays even when parent view has no results.,!7567Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7565Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7509Change label "Block description" to "Block type",!7344Issue #3292350 by O'Briat, KlemenDEV, hswong3i, smustgrave, quietone: Update...,!6922Issue #3412959 by quietone, smustgrave, longwave: Fix 12 'un' words,!6848Issue #3417553 by longwave: Remove withConsecutive() in CacheCollectorTest
Pipeline #104062 passed
Pipeline: drupal

#104087

    Pipeline: drupal

    #104080

      Pipeline: drupal

      #104075

        +1
        ...@@ -295,6 +295,8 @@ function file_validate_image_resolution(FileInterface $file, $maximum_dimensions ...@@ -295,6 +295,8 @@ function file_validate_image_resolution(FileInterface $file, $maximum_dimensions
        if ($image->scale($width, $height)) { if ($image->scale($width, $height)) {
        $scaling = TRUE; $scaling = TRUE;
        $image->save(); $image->save();
        // Update the file size now that the image has been resized.
        $file->setSize($image->getFileSize());
        if (!empty($width) && !empty($height)) { if (!empty($width) && !empty($height)) {
        $message = t('The image was resized to fit within the maximum allowed dimensions of %dimensions pixels. The new dimensions of the resized image are %new_widthx%new_height pixels.', $message = t('The image was resized to fit within the maximum allowed dimensions of %dimensions pixels. The new dimensions of the resized image are %new_widthx%new_height pixels.',
        [ [
        ......
        ...@@ -37,6 +37,7 @@ protected function setUp(): void { ...@@ -37,6 +37,7 @@ protected function setUp(): void {
        /** @var \Drupal\Core\File\FileSystemInterface $file_system */ /** @var \Drupal\Core\File\FileSystemInterface $file_system */
        $file_system = \Drupal::service('file_system'); $file_system = \Drupal::service('file_system');
        $this->image->setFilename($file_system->basename($this->image->getFileUri())); $this->image->setFilename($file_system->basename($this->image->getFileUri()));
        $this->image->setSize(@filesize($this->image->getFileUri()));
        $this->nonImage = File::create(); $this->nonImage = File::create();
        $this->nonImage->setFileUri('core/assets/vendor/jquery/jquery.min.js'); $this->nonImage->setFileUri('core/assets/vendor/jquery/jquery.min.js');
        ...@@ -191,6 +192,8 @@ public function testFileValidateImageResolution() { ...@@ -191,6 +192,8 @@ public function testFileValidateImageResolution() {
        // Verify that the image was scaled to the correct width and height. // Verify that the image was scaled to the correct width and height.
        $this->assertLessThanOrEqual(10, $image->getWidth()); $this->assertLessThanOrEqual(10, $image->getWidth());
        $this->assertLessThanOrEqual(5, $image->getHeight()); $this->assertLessThanOrEqual(5, $image->getHeight());
        // Verify that the file size has been updated after resizing.
        $this->assertEquals($this->image->getSize(), $image->getFileSize());
        // Once again, now with negative width and height to force an error. // Once again, now with negative width and height to force an error.
        copy('core/misc/druplicon.png', 'temporary://druplicon.png'); copy('core/misc/druplicon.png', 'temporary://druplicon.png');
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment