diff --git a/core/modules/filter/config/schema/filter.schema.yml b/core/modules/filter/config/schema/filter.schema.yml
index f1df7df..914131c 100644
--- a/core/modules/filter/config/schema/filter.schema.yml
+++ b/core/modules/filter/config/schema/filter.schema.yml
@@ -69,6 +69,13 @@ filter_settings.filter_html:
       type: boolean
       label: 'HTML nofollow'
 
+filter_settings.filter_html_image_secure:
+  type: filter
+  label: 'Filter HTML image secure'
+  mapping:
+    filter_html_image_secure_domains:
+      type: string
+      label: 'Accepted domains'
 
 filter_settings.filter_url:
   type: filter
diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module
index 40eda67..150ad81 100644
--- a/core/modules/filter/filter.module
+++ b/core/modules/filter/filter.module
@@ -1057,7 +1057,7 @@ function _filter_html_escape($text) {
 /**
  * Process callback for local image filter.
  */
-function _filter_html_image_secure_process($text) {
+function _filter_html_image_secure_process($text, $domains) {
   // Find the path (e.g. '/') to Drupal root.
   $base_path = base_path();
   $base_path_length = drupal_strlen($base_path);
@@ -1065,13 +1065,28 @@ function _filter_html_image_secure_process($text) {
   // Find the directory on the server where index.php resides.
   $local_dir = DRUPAL_ROOT . '/';
 
+  // Split $domains on newlines, trim whitespace, and construct a regexp to
+  // match them.
+  if (!empty($domains)) {
+    $domains_regexp = '#^https?://('
+      . implode('|', array_map('preg_quote',
+          array_map('trim', preg_split('/(\r\n?|\n)/', $domains))
+      ))
+      . ')(:\d+)?#';
+  }
+
   $html_dom = Html::load($text);
   $images = $html_dom->getElementsByTagName('img');
   foreach ($images as $image) {
     $src = $image->getAttribute('src');
     // Transform absolute image URLs to relative image URLs: prevent problems on
     // multisite set-ups and prevent mixed content errors.
-    $image->setAttribute('src', file_url_transform_relative($src));
+    if (isset($domains_regexp)) {
+      $image->setAttribute('src', preg_replace($domains_regexp, '', $src));
+    }
+    else {
+      $image->setAttribute('src', file_url_transform_relative($src));
+    }
 
     // Verify that $src starts with $base_path.
     // This also ensures that external images cannot be referenced.
diff --git a/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterHtmlImageSecure.php b/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterHtmlImageSecure.php
index f00b055..55ec8e2 100644
--- a/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterHtmlImageSecure.php
+++ b/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterHtmlImageSecure.php
@@ -17,6 +17,9 @@
  *   title = @Translation("Restrict images to this site"),
  *   description = @Translation("Disallows usage of &lt;img&gt; tag sources that are not hosted on this site by replacing them with a placeholder image."),
  *   type = Drupal\filter\Plugin\FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE,
+ *   settings = {
+ *     "filter_html_image_secure_domains" = ""
+ *   },
  *   weight = 9
  * )
  */
@@ -25,8 +28,21 @@ class FilterHtmlImageSecure extends FilterBase {
   /**
    * {@inheritdoc}
    */
+  public function settingsForm(array $form, array &$form_state) {
+    $form['filter_html_image_secure_domains'] = array(
+      '#type' => 'textarea',
+      '#title' => $this->t('Alternate domains'),
+      '#default_value' => $this->settings['filter_html_image_secure_domains'],
+      '#description' => $this->t('If your site reachable from muliple domains, such as example.com and www.example.com, list them one per line.'),
+    );
+    return $form;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
   public function process($text, $langcode, $cache, $cache_id) {
-    return _filter_html_image_secure_process($text);
+    return _filter_html_image_secure_process($text, $this->settings['filter_html_image_secure_domains']);
   }
 
   /**
