Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / filter / filter.api.php
1 <?php
2
3 /**
4  * @file
5  * Hooks provided by the Filter module.
6  */
7
8 /**
9  * @addtogroup hooks
10  * @{
11  */
12
13 /**
14  * Perform alterations on filter definitions.
15  *
16  * @param array $info
17  *   Array of information on filters exposed by filter plugins.
18  */
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,
23   ];
24 }
25
26 /**
27  * Alters images with an invalid source.
28  *
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.
32  *
33  * @param DOMElement $image
34  *   An IMG node to format, parsed from the filtered text.
35  */
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.'));
41
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);
46 }
47
48 /**
49  * Perform actions when a text format has been disabled.
50  *
51  * @param \Drupal\filter\FilterFormatInterface $format
52  *   The format object of the format being disabled.
53  */
54 function hook_filter_format_disable($format) {
55   mymodule_cache_rebuild();
56 }
57
58 /**
59  * @} End of "addtogroup hooks".
60  */