summaryrefslogtreecommitdiffstats
path: root/core/modules/filter/filter.api.php
diff options
context:
space:
mode:
authorwebchick2014-01-25 01:33:34 (GMT)
committerwebchick2014-01-25 01:40:01 (GMT)
commitb030ad56be8b77fdabe63e0f8cb939198e19e0bb (patch)
tree173d88e41f3ceb6dd273b4f990469788fca1e891 /core/modules/filter/filter.api.php
parentcc1892d4990794ee47c7cbdc8e922963eb84f635 (diff)
Issue #1898416 by Cottser, joelpittet, drupalninja99, mikl, drupalmonkey, bradwade, pwieck, ezeedub, kerasai, disasm | c4rl: Filter.module - Convert theme_ functions to Twig.
Diffstat (limited to 'core/modules/filter/filter.api.php')
-rw-r--r--core/modules/filter/filter.api.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/core/modules/filter/filter.api.php b/core/modules/filter/filter.api.php
index 8d6aa01..7f2c132 100644
--- a/core/modules/filter/filter.api.php
+++ b/core/modules/filter/filter.api.php
@@ -24,6 +24,28 @@ function hook_filter_info_alter(&$info) {
}
/**
+ * Alters images with an invalid source.
+ *
+ * When the 'Restrict images to this site' filter is enabled, any images that
+ * are not hosted on the site will be passed through this hook, most commonly to
+ * replace the invalid image with an error indicator.
+ *
+ * @param DOMElement $image
+ * An IMG node to format, parsed from the filtered text.
+ */
+function hook_filter_secure_image_alter(&$image) {
+ // Turn an invalid image into an error indicator.
+ $image->setAttribute('src', base_path() . 'core/misc/message-16-error.png');
+ $image->setAttribute('alt', t('Image removed.'));
+ $image->setAttribute('title', t('This image has been removed. For security reasons, only images from the local domain are allowed.'));
+
+ // Add a CSS class to aid in styling.
+ $class = ($image->getAttribute('class') ? trim($image->getAttribute('class')) . ' ' : '');
+ $class .= 'filter-image-invalid';
+ $image->setAttribute('class', $class);
+}
+
+/**
* Perform actions when a text format has been disabled.
*
* @param $format