diff --git a/core/modules/image/image.module b/core/modules/image/image.module
index 12fa4fd..0d43de1 100644
--- a/core/modules/image/image.module
+++ b/core/modules/image/image.module
@@ -489,7 +489,7 @@ function image_field_config_delete(FieldConfigInterface $field) {
* Implements hook_form_FORM_ID_alter().
*
* Alters the image dialog form for text editor, to allow the user to select an
- * image style.
+ * image style.
*
* @see \Drupal\editor\Form\EditorImageDialog::buildForm()
*/
@@ -498,7 +498,7 @@ function image_form_editor_image_dialog_alter(&$form, FormStateInterface $form_s
$editor = $form_state->getBuildInfo()['args'][0];
// Alter the editor image dialog when image style functionality is available.
- if ($editor->getFilterformat()->filters('filter_image_style')->status) {
+ if ($editor->getFilterFormat()->filters('filter_image_style')->status) {
// Get the image () that is being edited on the client.
$image_element = $form_state->getStorage()['image_element'];
@@ -506,14 +506,14 @@ function image_form_editor_image_dialog_alter(&$form, FormStateInterface $form_s
$image_style_options = image_style_options(FALSE);
// Add a select element to choose an image style.
- $form['image_style']['selection'] = array(
+ $form['image_style']['selection'] = [
'#title' => t('Image style'),
'#type' => 'select',
'#default_value' => isset($image_element['data-image-style']) ? $image_element['data-image-style'] : NULL,
'#options' => $image_style_options,
'#required' => TRUE,
- '#parents' => array('attributes', 'data-image-style'),
- );
+ '#parents' => ['attributes', 'data-image-style'],
+ ];
$form['actions']['save_modal']['#validate'][] = 'image_form_editor_image_dialog_validate';
}
@@ -552,10 +552,10 @@ function image_form_editor_image_dialog_validate(array &$form, FormStateInterfac
if ($image->isValid()) {
// Get the original width and height of the image.
- $dimensions = array(
+ $dimensions = [
'width' => $image->getWidth(),
'height' => $image->getHeight(),
- );
+ ];
// Transform the 'width' and 'height' dimensions of the image based on the
// image style.
diff --git a/core/modules/image/src/Plugin/CKEditorPlugin/DrupalImageStyle.php b/core/modules/image/src/Plugin/CKEditorPlugin/DrupalImageStyle.php
index d076508..98fbd1a 100644
--- a/core/modules/image/src/Plugin/CKEditorPlugin/DrupalImageStyle.php
+++ b/core/modules/image/src/Plugin/CKEditorPlugin/DrupalImageStyle.php
@@ -63,8 +63,8 @@ public function isEnabled(Editor $editor) {
}
// Automatically enable this plugin if the text format associated with this
- // text editor uses the filter_image_style filter and the DrupalImage
- // button is enabled.
+ // text editor uses the filter_image_style filter and the DrupalImage button
+ // is enabled.
$format = $editor->getFilterFormat();
if ($format->filters('filter_image_style')->status) {
$toolbarButtons = CKEditorPluginManager::getEnabledButtons($editor);
diff --git a/core/modules/image/src/Plugin/Filter/FilterImageStyle.php b/core/modules/image/src/Plugin/Filter/FilterImageStyle.php
index 328daed..77a36b4 100644
--- a/core/modules/image/src/Plugin/Filter/FilterImageStyle.php
+++ b/core/modules/image/src/Plugin/Filter/FilterImageStyle.php
@@ -93,14 +93,14 @@ public static function create(ContainerInterface $container, array $configuratio
*/
public function process($text, $langcode) {
if (stristr($text, 'data-image-style') !== FALSE) {
- // Load all image styles so each image found in the text can be
- // checked against a valid image style.
+ // Load all image styles so each image found in the text can be checked
+ // against a valid image style.
$image_styles = $this->loadImageStyles();
- $dom = HTML::load($text);
+ $dom = Html::load($text);
$xpath = new \DOMXPath($dom);
- // Process each img element found with the necessary attributes.
+ // Process each image element found with the necessary attributes.
/** @var \DOMElement $dom_element */
foreach ($xpath->query('//*[@data-entity-type="file" and @data-entity-uuid and @data-image-style]') as $dom_element) {
// Get the UUID and image style for the file.
@@ -108,7 +108,6 @@ public function process($text, $langcode) {
$image_style_id = $dom_element->getAttribute('data-image-style');
// If the image style is not a valid one, then don't transform the HTML.
- // @TODO: File a follow-up. See #222-26.
if (empty($file_uuid) || !in_array($image_style_id, $image_styles)) {
continue;
}
@@ -120,7 +119,7 @@ public function process($text, $langcode) {
$dom_element->parentNode->replaceChild($altered_img, $dom_element);
}
- return new FilterProcessResult(HTML::serialize($dom));
+ return new FilterProcessResult(Html::serialize($dom));
}
// Process the filter if no image style img elements are found.
@@ -138,7 +137,7 @@ protected function loadImageStyles() {
}
/**
- * Get the the width and height of an image based on the file UUID.
+ * Gets the the width and height of an image based on the file UUID.
*
* @param string $file_uuid
* The UUID for the file.
@@ -176,12 +175,6 @@ protected function getImageInfo($file_uuid) {
* The attributes array.
*/
protected function prepareImageAttributes(\DOMElement $dom_element) {
- // Remove attributes that are no longer needed.
- // @TODO: File a follow-up. See #222-27.
- $dom_element->removeAttribute('data-entity-type');
- $dom_element->removeAttribute('data-entity-uuid');
- $dom_element->removeAttribute('data-image-style');
-
// Remove attributes that are generated by the image style.
$dom_element->removeAttribute('width');
$dom_element->removeAttribute('height');
@@ -198,7 +191,7 @@ protected function prepareImageAttributes(\DOMElement $dom_element) {
}
/**
- * Get the HTML for the img element after image style is applied.
+ * Gets the HTML for the image element after image style is applied.
*
* @param string $file_uuid
* The UUID for the file.
diff --git a/core/modules/image/tests/src/Functional/FilterImageStyleTest.php b/core/modules/image/tests/src/Functional/FilterImageStyleTest.php
index 63528cb..2c403d6 100644
--- a/core/modules/image/tests/src/Functional/FilterImageStyleTest.php
+++ b/core/modules/image/tests/src/Functional/FilterImageStyleTest.php
@@ -8,6 +8,8 @@
use Drupal\Core\Url;
/**
+ * Tests FilterImageStyle conversion of inline images to utilize image styles.
+ *
* @coversDefaultClass \Drupal\image\Plugin\Filter\FilterImageStyle
* @group image
*/
@@ -20,9 +22,9 @@ class FilterImageStyleTest extends BrowserTestBase {
public static $modules = ['filter', 'file', 'editor', 'node', 'image'];
/**
- * Text filter allowing images and has FilterImageStyle applied.
+ * A text format allowing images and with FilterImageStyle applied.
*
- * @var \Drupal\Core\Entity\EntityInterface
+ * @var \Drupal\Filter\FilterFormatInterface
*/
protected $format;
@@ -37,13 +39,13 @@ protected function setUp() {
'name' => $this->randomString(),
'filters' => [
'filter_html' => [
- 'status' => 1,
+ 'status' => TRUE,
'settings' => [
'allowed_html' => '',
],
],
- 'filter_image_style' => ['status' => 1],
- 'editor_file_reference' => ['status' => 1],
+ 'filter_image_style' => ['status' => TRUE],
+ 'editor_file_reference' => ['status' => TRUE],
],
]);
$this->format->save();
@@ -109,10 +111,6 @@ public function testImageStyle() {
$image_element = $this->getSession()->getPage()->find('css', 'img.image-style-medium');
$this->assertFalse(empty($image_element));
- $this->assertFalse($image_element->hasAttribute('data-entity-type'));
- $this->assertFalse($image_element->hasAttribute('data-entity-uuid'));
- $this->assertFalse($image_element->hasAttribute('data-image-style'));
-
$this->assertTrue(strpos($image_element->getAttribute('src'), 'medium'));
$this->assertEquals('220', $image_element->getAttribute('width'));
$this->assertEquals('164', $image_element->getAttribute('height'));
diff --git a/core/modules/image/tests/src/FunctionalJavascript/AddImageTest.php b/core/modules/image/tests/src/FunctionalJavascript/AddImageTest.php
index 2b33a5b..e4cc8f6 100644
--- a/core/modules/image/tests/src/FunctionalJavascript/AddImageTest.php
+++ b/core/modules/image/tests/src/FunctionalJavascript/AddImageTest.php
@@ -32,7 +32,7 @@ protected function setUp() {
'format' => 'filtered_html',
'name' => $this->randomString(),
'filters' => [
- 'filter_image_style' => ['status' => 1],
+ 'filter_image_style' => ['status' => TRUE],
],
]);
$format->save();