Qartvela™ Posted March 12, 2018 Share Posted March 12, 2018 Здравствуйте Нужно добавить уникальный ID для картинок в темах, для новых и для старых тоже. admin/sources/classes/text/parser/html.php if ( ! parent::$Perms['parseHtml'] ) { $uniqid_forimages = uniqid(); $html = preg_replace( "/(?!<span rel='lightbox'>)<img(?!.*sharedmedia_screenshot)([^>]+?)>/i", "<span rel='lightbox'><img class='bbc_img' id='" . $uniqid_forimages . "'\\1></span>", $html ); $html = preg_replace( "/<img class='bbc_img'([^>]+?)class='bbc_img'([^>]+?)>/i", "<img class='bbc_img'\\1\\2>", $html ); } Но...1) Если в посте загрузить или вставить через img bbcode несколько картинка, тогда для всех добавляется одинаковые ID.2) Нужно еще добавить для старых картинок. Link to comment Share on other sites More sharing options...
newbie Posted March 12, 2018 Share Posted March 12, 2018 Как вариант $html = preg_replace_callback( "/<img class='bbc_img'/i", function ($matches) { return $matches[0] . ' id="' . uniqid() . '"'; }, $html ); php $html = preg_replace_callback( "/<img class='bbc_img'/i", create_function('$matches', 'return $matches[0] . \' id="\' . uniqid() . \'"\';'), $html );Либо $html = preg_replace_callback( "/<img class='bbc_img'/i", array($this, 'addIdToImages'), $html ); и добавить метод protected function addIdToImages($matches) { return $matches[0] . ' id="' . uniqid() . '"'; } 2) Нужно еще добавить для старых картинок. Нужно удалить кеш постов 1 Link to comment Share on other sites More sharing options...
Qartvela™ Posted March 12, 2018 Author Share Posted March 12, 2018 Parse error: syntax error, unexpected T_FUNCTION in /admin/sources/classes/text/parser/html.php on line 111 Link to comment Share on other sites More sharing options...
newbie Posted March 12, 2018 Share Posted March 12, 2018 php версии ниже 5.3? Link to comment Share on other sites More sharing options...
Qartvela™ Posted March 12, 2018 Author Share Posted March 12, 2018 PHP Version 5.2.42 Link to comment Share on other sites More sharing options...
newbie Posted March 12, 2018 Share Posted March 12, 2018 Я добавил вариант для php 1 Link to comment Share on other sites More sharing options...
Qartvela™ Posted March 12, 2018 Author Share Posted March 12, 2018 Огромное спасибо. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now