103acf9148f0895e79200a56bb7730a367143c7d
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / hook / filter_secure_image_alter.twig
1 /**
2  * Implements hook_filter_secure_image_alter().
3  */
4 function {{ machine_name }}_filter_secure_image_alter(&$image) {
5   // Turn an invalid image into an error indicator.
6   $image->setAttribute('src', base_path() . 'core/misc/icons/e32700/error.svg');
7   $image->setAttribute('alt', t('Image removed.'));
8   $image->setAttribute('title', t('This image has been removed. For security reasons, only images from the local domain are allowed.'));
9
10   // Add a CSS class to aid in styling.
11   $class = ($image->getAttribute('class') ? trim($image->getAttribute('class')) . ' ' : '');
12   $class .= 'filter-image-invalid';
13   $image->setAttribute('class', $class);
14 }