diff --git a/core/modules/editor/js/editor.dialog.js b/core/modules/editor/js/editor.dialog.js index ad44c4b..b52add1 100644 --- a/core/modules/editor/js/editor.dialog.js +++ b/core/modules/editor/js/editor.dialog.js @@ -31,8 +31,14 @@ $(window).trigger('editor:dialogsave', [response.values]); }; + /** + * Add change event to source radio buttons. + * + * It toggles display of url and file field depending on selected source. + */ Drupal.behaviors.imageSourceChange = { attach: function (context, settings) { + // Change event on the source radio buttons. $('input[name=source]', context).change(function () { $('#fid-field', context).toggleClass('hidden'); $('#src-field', context).toggleClass('hidden'); diff --git a/core/modules/editor/src/Form/EditorImageDialog.php b/core/modules/editor/src/Form/EditorImageDialog.php index d511e86..7889eef 100644 --- a/core/modules/editor/src/Form/EditorImageDialog.php +++ b/core/modules/editor/src/Form/EditorImageDialog.php @@ -96,6 +96,8 @@ public function buildForm(array $form, FormStateInterface $form_state, FilterFor $existing_file = isset($image_element['data-entity-uuid']) ? \Drupal::entityManager()->loadEntityByUuid('file', $image_element['data-entity-uuid']) : NULL; $fid = $existing_file ? $existing_file->id() : NULL; + // Radio buttons to select the image source: url or file. This is only + // displayed if the editor has image uploads enabled. $form['source'] = array( '#title' => $this->t('Source'), '#type' => 'radios', @@ -138,8 +140,7 @@ public function buildForm(array $form, FormStateInterface $form_state, FilterFor '#suffix' => '', ); - // If the editor has image uploads enabled, show a managed_file form item, - // otherwise show a (file URL) text form item. + // If the editor has image uploads enabled, show a managed_file form item. if (!$image_upload['status']) { $form['fid']['#access'] = FALSE; $form['fid']['#required'] = FALSE;