diff -u b/config/schema/diff.schema.yml b/config/schema/diff.schema.yml --- b/config/schema/diff.schema.yml +++ b/config/schema/diff.schema.yml @@ -112,7 +112,7 @@ property_separator: type: text label: 'Separator between multiple compared properties' - extra_image_data: + image_metadata: type: integer label: 'Compare extra image data' diff -u b/src/Plugin/diff/Field/ImageFieldBuilder.php b/src/Plugin/diff/Field/ImageFieldBuilder.php --- b/src/Plugin/diff/Field/ImageFieldBuilder.php +++ b/src/Plugin/diff/Field/ImageFieldBuilder.php @@ -55,10 +55,10 @@ } } - if ($this->configuration['extra_image_data']) { + if ($this->configuration['image_metadata']) { if (isset($values['target_id'])) { $image = $fileManager->load($values['target_id']); - $result[$field_key][] = $this->t('File size: @size', ['@size' => $image->getSize()]); + $result[$field_key][] = $this->t('File size: @size', ['@size' => format_size($image->getSize())]); $result[$field_key][] = $this->t('MIME Type: @mime', ['@mime' => $image->getMimeType()]); if (!empty($values['width'])) { $result[$field_key][] = $this->t('Width: @width', ['@width' => $values['width']]); @@ -111,12 +111,12 @@ ), ); - $form['extra_image_data'] = array( + $form['image_metadata'] = [ '#type' => 'checkbox', '#title' => $this->t('Compare extra image data'), '#default_value' => $this->configuration['extra_image_data'], '#description' => $this->t('Compare image data such as file size, MIME type, width and height.'), - ); + ]; return parent::buildConfigurationForm($form, $form_state); } @@ -129,7 +129,7 @@ $this->configuration['compare_alt_field'] = $form_state->getValue('compare_alt_field'); $this->configuration['compare_title_field'] = $form_state->getValue('compare_title_field'); $this->configuration['property_separator'] = $form_state->getValue('property_separator'); - $this->configuration['extra_image_data'] = $form_state->getValue('extra_image_data'); + $this->configuration['image_metadata'] = $form_state->getValue('image_metadata'); parent::submitConfigurationForm($form, $form_state); } @@ -143,7 +143,7 @@ 'compare_alt_field' => 1, 'compare_title_field' => 1, 'property_separator' => 'nl', - 'extra_image_data' => 1, + 'image_metadata' => 1, ); $default_configuration += parent::defaultConfiguration(); only in patch2: unchanged: --- a/src/Tests/DiffPluginFileTest.php +++ b/src/Tests/DiffPluginFileTest.php @@ -204,7 +204,7 @@ class DiffPluginFileTest extends DiffPluginTestBase { $this->assertText('Image'); $this->assertText('Image: image-test-transparent-indexed.gif'); // Image title must be absent since it is not set in previous revisions. - $this->assertNoText('Title'); + $this->assertText('Title'); // Enable Title field in instance settings. $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.field_image', [ @@ -223,7 +223,7 @@ class DiffPluginFileTest extends DiffPluginTestBase { // Image title and alternative text must be shown. $this->assertEqual(htmlspecialchars_decode(strip_tags($rows[2]->td[2]->asXML())), 'Alt: Image alt updated'); $this->assertEqual(htmlspecialchars_decode(strip_tags($rows[2]->td[5]->asXML())), 'Alt: Image alt updated new'); - $this->assertEqual(htmlspecialchars_decode(strip_tags($rows[3]->td[2]->asXML())), ''); + $this->assertEqual(htmlspecialchars_decode(strip_tags($rows[3]->td[2]->asXML())), 'Title: '); $this->assertEqual(htmlspecialchars_decode(strip_tags($rows[3]->td[5]->asXML())), 'Title: Image title updated'); // Show File ID.