getPath(), '.', 2); $hasThumbnail = $ext !== null && in_array($ext, static::$IMAGE_FILES, true); $useIframe = $ext !== null && ! in_array($ext, static::$NON_IFRAME_FILES, true); if ($hasThumbnail) { // I would have liked to not only base this off of the extension, but also by // whether there is an actual img tag inside the anchor. Seems not possible :( $attr['class'] = 'with-thumbnail'; } if ((! isset($attr['target']) || ! in_array($attr['target'], ['_blank', '_self'])) && ($useIframe || $url->isExternal()) ) { $attr['href'] = Url::fromPath('iframe', ['url' => $url])->getAbsoluteUrl(); } return $attr; } public static function attachTo(HTMLPurifier_Config $config) { $module = $config->getHTMLDefinition(true) ->getAnonymousModule(); if (isset($module->info['a'])) { $a = $module->info['a']; } else { $a = $module->addBlankElement('a'); } $a->attr_transform_post[] = new self(); } }