Qartvela™ 24 12/20/2017 10:03 AM То есть... Когда открываешь тему и добавляешь картинки в виде: [img=http://site.com/image.jpg]или [img=http://site.com/image.jpg]А потом делишься ссылкой темы или поста на фейсбук, он (фейсбук) не видит картинку из темы и отображает стандартную картинку og:image Но если добавляешь картинку через стандартную функцию "Attachment" тогда фейсбук видит и загружает картинку в диалоговом окне. Как эту проблему решит? Share this post Link to post Share on other sites
Qartvela™ 24 12/20/2017 11:49 AM Но если устанавливаю это hook bim_image_meta_tag_hook.rar тогда фейсбук находит картинку, но из первого поста. А бывает что в первом посте только текст написано :( Hook details:Automatically retrieve the first image from the article (including the attached image) and then add it to the meta tag "og: image". So when you share posts on facebook or other social networks it will have that screenshots instead of the fixed meta_image.png image of the IPB.https://ipsviet.com/topic/35915-bim34-image-meta-tag-101/ Share this post Link to post Share on other sites
newbie 1,720 12/20/2017 11:50 AM FB и не должен картинки искать.Зайдя на страница, он ищет теги Open Graph. Для изображения это og:image. Если в посте есть вложения, то тег добавляется автоматически на страницу. Share this post Link to post Share on other sites
Qartvela™ 24 12/20/2017 11:56 AM Тогда как добавить картинки в og:image которые вставлены через bbcode? [img=http://site.com/image.jpg]или [img=http://site.com/image.jpg] Если в посте есть вложения, то тег добавляется автоматически на страницу.Конечно есть, но не добавляется. Например... Из одной темы с форума, где точно вставлены картинки, В FireBug видно картинка который задан для og:image<meta property="og:image" content="http://site.com/fb_600_315.jpg"/>В https://developers.facebook.com/tools/debug/ & https://developers.facebook.com/tools/debug/og/object/ тоже самое. Share this post Link to post Share on other sites
Qartvela™ 24 12/21/2017 06:20 AM Кстати, тоже самое с G+ один в один. Share this post Link to post Share on other sites
Trotor 26 12/21/2017 06:35 AM Точно. Аналогичная проблема. Стоит: <meta property="og:image" content="{$this->settings['meta_imagesrc']}" /> 1 Share this post Link to post Share on other sites
Trotor 26 12/21/2017 06:38 AM Вот ещё об этой проблеме - http://qaru.site/questions/28878/fb-opengraph-ogimage-not-pulling-images-possibly-https 1 Share this post Link to post Share on other sites
Qartvela™ 24 12/21/2017 08:26 AM В моем случае проблема в системе форума, он скрывает картинки для фейсбука и G+ которые вставлены с помощью bbcode. Share this post Link to post Share on other sites
newbie 1,720 12/21/2017 10:08 AM В моем случае проблема в системе форума, он скрывает картинки для фейсбука и G+ которые вставлены с помощью bbcode. Форум и не должен их показывать.Когда Вы добавляете аттачмент в виде картинки, то при отображении страницы темы добавляется тег og:image в код страницы.Если нужен такой же трюк с обычными картинками, вставленными при помощи бибикода img, то нужно из постов вытаскивать изображения и добавлять og:image Share this post Link to post Share on other sites
Qartvela™ 24 12/22/2017 06:05 AM @newbieто нужно из постов вытаскивать изображения и добавлять og:image Понятно. Как это сделать? Share this post Link to post Share on other sites
newbie 1,720 12/22/2017 07:58 AM Понятно. Как это сделать? Например, добавить в шаблон postpreg_match('~<img[^>]*?src="([^"]*)"[^>]*>~i', $post['post']['post'], $matches); if ($matches[1]) { $this->registry->output->addMetaTag('og:image', $matches[1], false); } 1 Share this post Link to post Share on other sites
Qartvela™ 24 12/22/2017 08:55 AM @newbieСупер! Работает! Спасибо большое! Share this post Link to post Share on other sites
Qartvela™ 24 12/23/2017 07:51 AM Сделал так: 1) С globalTemplate убрал и вставил в boardIndexTemplate:<meta property="og:image" content="{$this->settings['meta_imagesrc']}"/>Можно делать условие и оставить в globalTemplate:<if this not a topick> <meta property="og:image" content="{$this->settings['meta_imagesrc']}"/> </if> 2) В шаблоне post:preg_match('~<img[^>]*?src="([^"]*)"[^>]*>~i', $post['post']['post'], $matches); if ($matches[1]) { $this->registry->output->addMetaTag('og:image', $matches[1], false); } else if ($matches[0]) { $this->registry->output->addMetaTag('og:image', str_replace("\r", "", $this->settings['meta_imagesrc'] ), FALSE ); } Сделал так потому что фейсбук сначало видел стандартную meta_imagesrc и брал его в кэш.Щас когда нажимаю поделиться в окно показывается информация без картинки, закрываю окно и заново нажимаю поделиться, в открытом окне все показывается нормально. Или просто F5.Это можно исправить? Share this post Link to post Share on other sites
Qartvela™ 24 03/27/2019 05:43 AM Здравствуйте <php> if (preg_match('~<img[^>]*(bbc[^>]*img*)[^>]*src="([^"]*)"[^>]*?>~i', $post['post']['post'], $matches, PREG_OFFSET_CAPTURE, 0)) { print_r($matches[2]); $this->registry->output->addMetaTag('og:image', $matches[2]); } else { print_r($matches[2]); echo 'Not found'; $this->registry->output->addMetaTag('og:image', $this->settings['meta_imagesrc']); } </php> Если картинка найдена выводит:Not foundNot foundArray ( [0] => https://site.com/uploads/1.jpg [1] => 3240 ) Array ( [0] => https://site.com/uploads/2.jpg [1] => 1064 ) Not foundNot foundNot foundArray ( [0] => https://site.com/uploads/3.jpg [1] => 3185 ) Not foundNot foundNot foundNot foundNot foundArray ( [0] => https://site.com/uploads/4.jpg [1] => 1084 ) Not found Не понимаю что ему не нравится :( Share this post Link to post Share on other sites
siv1987 2,622 03/27/2019 08:29 AM Вам newbie написал другой вариант preg_match, зачем надо было менять формат? else там явно лишний, потому что по умолчанию и так будет дефолтная картинка. Этот код также отрабатывает для всех сообщений в теме, не только первой. Возможно имеет смысл ограничить только первым сообщением, или первой найденной картинкой. Share this post Link to post Share on other sites