/** * Handles IMG tags. * * @param string $text Child text of the tag (probably none) * @param XenForo_Html_Tag $tag HTML tag triggering call * * @return string */ public function handleTagImg($text, XenForo_Html_Tag $tag) { if (($tag->attribute('class') == 'mceSmilie' || $tag->attribute('data-smilie')) && $tag->attribute('alt')) { // regular image smilies $output = trim($tag->attribute('alt')); } else { if (strpos($tag->attribute('class'), 'mceSmilieSprite') !== false && $tag->attribute('alt')) { // sprite smilies $output = trim($tag->attribute('alt')); } else { if (preg_match('#attach(Thumb|Full)(\\d+)#', $tag->attribute('alt'), $match)) { if ($match[1] == 'Full') { $output = '[ATTACH=full]' . $match[2] . '[/ATTACH]'; } else { $output = '[ATTACH]' . $match[2] . '[/ATTACH]'; } } else { $src = $tag->attribute('src'); $output = ''; if (preg_match('#^(data:|blob:|webkit-fake-url:)#i', $src)) { // data URI - ignore } else { if ($src) { if (XenForo_Application::isRegistered('smilies')) { $smilies = XenForo_Application::get('smilies'); } else { $smilies = XenForo_Model::create('XenForo_Model_Smilie')->getAllSmiliesForCache(); XenForo_Application::set('smilies', $smilies); } foreach ($smilies as $smilie) { if ($src == $smilie['image_url']) { $output = reset($smilie['smilieText']); break; } } if (!$output) { $output = "[IMG]" . $this->convertUrlToAbsolute($src) . "[/IMG]"; } } } } } } return $this->renderCss($tag, $output); }