5 * Hooks provided by the Filter module.
14 * Perform alterations on filter definitions.
17 * Array of information on filters exposed by filter plugins.
19 function hook_filter_info_alter(&$info) {
20 // Alter the default settings of the URL filter provided by core.
21 $info['filter_url']['default_settings'] = [
22 'filter_url_length' => 100,
27 * Alters images with an invalid source.
29 * When the 'Restrict images to this site' filter is enabled, any images that
30 * are not hosted on the site will be passed through this hook, most commonly to
31 * replace the invalid image with an error indicator.
33 * @param DOMElement $image
34 * An IMG node to format, parsed from the filtered text.
36 function hook_filter_secure_image_alter(&$image) {
37 // Turn an invalid image into an error indicator.
38 $image->setAttribute('src', base_path() . 'core/misc/icons/e32700/error.svg');
39 $image->setAttribute('alt', t('Image removed.'));
40 $image->setAttribute('title', t('This image has been removed. For security reasons, only images from the local domain are allowed.'));
42 // Add a CSS class to aid in styling.
43 $class = ($image->getAttribute('class') ? trim($image->getAttribute('class')) . ' ' : '');
44 $class .= 'filter-image-invalid';
45 $image->setAttribute('class', $class);
49 * Perform actions when a text format has been disabled.
51 * @param \Drupal\filter\FilterFormatInterface $format
52 * The format object of the format being disabled.
54 function hook_filter_format_disable($format) {
55 mymodule_cache_rebuild();
59 * @} End of "addtogroup hooks".