Skip to content
Snippets Groups Projects
Select Git revision
  • 0018b94fa186a8d2d1439f7a47385cbfac468bf0
  • 11.x default protected
  • 11.2.x protected
  • 10.6.x protected
  • 10.5.x protected
  • 11.1.x protected
  • 10.4.x protected
  • 11.0.x protected
  • 10.3.x protected
  • 7.x protected
  • 10.2.x protected
  • 10.1.x protected
  • 9.5.x protected
  • 10.0.x protected
  • 9.4.x protected
  • 9.3.x protected
  • 9.2.x protected
  • 9.1.x protected
  • 8.9.x protected
  • 9.0.x protected
  • 8.8.x protected
  • 10.5.1 protected
  • 11.2.2 protected
  • 11.2.1 protected
  • 11.2.0 protected
  • 10.5.0 protected
  • 11.2.0-rc2 protected
  • 10.5.0-rc1 protected
  • 11.2.0-rc1 protected
  • 10.4.8 protected
  • 11.1.8 protected
  • 10.5.0-beta1 protected
  • 11.2.0-beta1 protected
  • 11.2.0-alpha1 protected
  • 10.4.7 protected
  • 11.1.7 protected
  • 10.4.6 protected
  • 11.1.6 protected
  • 10.3.14 protected
  • 10.4.5 protected
  • 11.0.13 protected
41 results

filter.api.php

Blame
  • Nathaniel Catchpole's avatar
    Issue #1811328 by sushyl, Mile23: Add missing type hinting to Filter module docblocks
    catch authored
    16f03420
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    filter.api.php 1.64 KiB
    <?php
    
    /**
     * @file
     * Hooks provided by the Filter module.
     */
    
    /**
     * @addtogroup hooks
     * @{
     */
    
    /**
     * Perform alterations on filter definitions.
     *
     * @param array $info
     *   Array of information on filters exposed by filter plugins.
     */
    function hook_filter_info_alter(&$info) {
      // Alter the default settings of the URL filter provided by core.
      $info['filter_url']['default_settings'] = array(
        'filter_url_length' => 100,
      );
    }
    
    /**
     * 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/icons/e32700/error.svg');
      $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 \Drupal\filter\FilterFormatInterface $format
     *   The format object of the format being disabled.
     */
    function hook_filter_format_disable($format) {
      mymodule_cache_rebuild();
    }
    
    /**
     * @} End of "addtogroup hooks".
     */