[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/vendor/s9e/text-formatter/src/Plugins/Autoimage/ -> Configurator.php (source)

   1  <?php
   2  
   3  /**
   4  * @package   s9e\TextFormatter
   5  * @copyright Copyright (c) 2010-2022 The s9e authors
   6  * @license   http://www.opensource.org/licenses/mit-license.php The MIT License
   7  */
   8  namespace s9e\TextFormatter\Plugins\Autoimage;
   9  
  10  use s9e\TextFormatter\Plugins\ConfiguratorBase;
  11  
  12  class Configurator extends ConfiguratorBase
  13  {
  14      /**
  15      * @var string Name of attribute that stores the image's URL
  16      */
  17      protected $attrName = 'src';
  18  
  19      /**
  20      * @var string
  21      */
  22      protected $quickMatch = '://';
  23  
  24      /**
  25      * @var string
  26      */
  27      protected $regexp = '#\\bhttps?://[-.\\w]+/(?:[-+.:/\\w]|%[0-9a-f]{2}|\\(\\w+\\))+\\.(?:gif|jpe?g|png|svgz?|webp)(?!\\S)#i';
  28  
  29      /**
  30      * @var string Name of the tag used to represent images
  31      */
  32      protected $tagName = 'IMG';
  33  
  34      /**
  35      * Creates the tag used by this plugin
  36      *
  37      * @return void
  38      */
  39  	protected function setUp()
  40      {
  41          if (isset($this->configurator->tags[$this->tagName]))
  42          {
  43              return;
  44          }
  45  
  46          // Create a tag
  47          $tag = $this->configurator->tags->add($this->tagName);
  48  
  49          // Add an attribute using the default url filter
  50          $filter = $this->configurator->attributeFilters->get('#url');
  51          $tag->attributes->add($this->attrName)->filterChain->append($filter);
  52  
  53          // Set the default template
  54          $tag->template = '<img src="{@' . $this->attrName . '}"/>';
  55      }
  56  }


Generated: Mon Nov 25 19:05:08 2024 Cross-referenced by PHPXref 0.7.1