Example #1
0
 /**
  * Use the content as the image source.
  *
  * @param array $tag
  * @param string $content
  * @return string
  */
 public function parse(array $tag, $content)
 {
     // If more than 1 http:// is found in the string, possible XSS attack
     if (mb_substr_count($content, 'http://') + mb_substr_count($content, 'https://') > 1) {
         return null;
     }
     $tag['attributes']['src'] = $content;
     if (!empty($tag['attributes']['default'])) {
         list($width, $height) = explode('x', $tag['attributes']['default']);
         $tag['attributes']['width'] = $width;
         $tag['attributes']['height'] = $height;
     }
     if (empty($tag['attributes']['alt'])) {
         $tag['attributes']['alt'] = '';
     }
     return parent::parse($tag, $content);
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function parse(array $tag, $content)
 {
     $tag['attributes']['class'] = 'js-content-image';
     return parent::parse($tag, $content);
 }