Skip to content
Snippets Groups Projects

Issue #3436526: Adjust custom logo dimensions

Closed Pablo López requested to merge issue/drupal-3436526:3436526-create-image-styles into 11.x
4 unresolved threads

Closes #3436526

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
212 $logo_managed = $form_state->getValue('logo_managed');
213 $config = $this->config('navigation.settings');
214 if (empty($logo_managed)) {
215 return;
216 }
217
218 // Skip if the fid has not been modified.
219 $fid = reset($logo_managed);
220 if ($fid == $config->get('logo_managed')) {
221 return;
222 }
223
224 $file = $this->entityTypeManager->getStorage('file')
225 ->load($fid);
226 if ($fid && !$this->adjustLogoDimensions($file)) {
227 /* cspell:disable-next-line */
  • 62 // saved as permanent if settings are not submitted.
    63 $image_field = $this->assertSession()->hiddenFieldExists('logo_managed[fids]');
    64 $file = File::load($image_field->getValue());
    65 $this->assertFalse($file->isPermanent());
    66
    67 $page->pressButton('Save configuration');
    68 \Drupal::entityTypeManager()->getStorage('file')->resetCache();
    69
    70 $this->drupalGet("/admin/config/user-interface/navigation/settings");
    71
    72 // Assert the uploaded file is saved as permanent.
    73 $image_field = $this->assertSession()->hiddenFieldExists('logo_managed[fids]');
    74 $file = File::load($image_field->getValue());
    75 $this->assertTrue($file->isPermanent());
    76
    77 // Ensure that image has been resized to fit in the expected container.
  • 26 26 return $needs_save;
    27 27 });
    28 28 }
    29
    30 /**
    31 * Defines the values for the default logo dimensions and adjust the logo.
  • Some minor changes that I will push changes for.

  • quietone added 1 commit

    added 1 commit

    Compare with previous version

  • 214 $logo_managed = $form_state->getValue('logo_managed');
    215 $config = $this->config('navigation.settings');
    216 if (empty($logo_managed)) {
    217 return;
    218 }
    219
    220 // Skip if the fid has not been modified.
    221 $fid = reset($logo_managed);
    222 if ($fid == $config->get('logo_managed')) {
    223 return;
    224 }
    225
    226 $file = $this->entityTypeManager->getStorage('file')
    227 ->load($fid);
    228 if ($fid && !$this->adjustLogoDimensions($file)) {
    229 $form_state->setErrorByName('logo_managed', 'Image dimensions are bigger than the expected %widthx%heightpx and cannot be used as Navigation logo');
    • Related to @quietone's remarks here, I see a couple of problems with this. First, the error message is not translated. Second, I think the intention is to interpolate the width and height into the message. Finally, we should present the width and height in the error message the same as in adjustLogoDimensions to be consistent. I'll take a stab at fixing these. That will remove the need for the cspell exception.

    • m4olivei changed this line in version 9 of the diff

      changed this line in version 9 of the diff

    • Please register or sign in to reply
  • m4olivei added 1 commit

    added 1 commit

    Compare with previous version

  • Please register or sign in to reply
    Loading