- Posts: 6
COMMUNITY FORUM
Problem with image share on facebook
- Dimitris
-
Topic Author
- Offline
- New Member
Every time i try to share an article on facebook always the second image is selected and not the image that i set from image tab.
Any suggestions?
Please Log in or Create an account to join the conversation.
- Javi Mata
-
- Offline
- Senior Member
<meta property="og:url" content="www.nytimes.com/2015/02/19/arts/international/when-great-minds-dont-think-alike.html" />
<meta property="og:type" content="article" />
<meta property="og:title" content="When Great Minds Don’t Think Alike" />
<meta property="og:description" content="How much does culture influence creative thinking?" />
<meta property="og:image" content="static01.nyt.com/images/2015/02/19/arts/international/19iht-btnumbers19A/19iht-btnumbers19A-facebookJumbo-v2.jpg" />
Twitter: @Javi_Mata
Web: www.javimata.com
Please Log in or Create an account to join the conversation.
- Dimitris
-
Topic Author
- Offline
- New Member
- Posts: 6
Thank you for your reply.
How do i do that from k2?
Heew is an example of an article from the website :
beautymag.tips/nailsh/item/67-dye-another-day
Please Log in or Create an account to join the conversation.
- Javi Mata
-
- Offline
- Senior Member
$doc =& JFactory::getDocument();
$doc->setMetaData( 'og:image', $this->item->image );
the another meta's are added automatic
Twitter: @Javi_Mata
Web: www.javimata.com
Please Log in or Create an account to join the conversation.
- Dimitris
-
Topic Author
- Offline
- New Member
- Posts: 6
components/com_k2/views/item/view.html.php
Please Log in or Create an account to join the conversation.
- Javi Mata
-
- Offline
- Senior Member
after of: defined('_JEXEC') or die;
$doc =& JFactory::getDocument();
$doc->setMetaData( 'og:image', $this->item->image );
BEST be if add a new folder in templates/html/com_k2/[A LAYOUT]/item.php
create a folder in templates/html/com_k2/with a name like: articles (or every you want)
copy all files of components/com_k2/templates/default/ to the new folder, then in the category panel change the layout to this
and the change do it in the file item.php in the new folder, this is a override layout
Twitter: @Javi_Mata
Web: www.javimata.com
Please Log in or Create an account to join the conversation.
- Dimitris
-
Topic Author
- Offline
- New Member
- Posts: 6
I will do it and let you know what happened.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Make sure that another extension is not printing its own.
I would not suggest editing core files, since you will lose all edits when you update.
Please Log in or Create an account to join the conversation.
- Dimitris
-
Topic Author
- Offline
- New Member
- Posts: 6
I didn't try the solution suggested by Javi because of what Krikor said.
The problem is still present. Unless i debug the link with facebook debugger images sometimes wont work at all. Even after debugging the images wont work again after some time.
The only extension that could cause problem is JCH optimize but i think i have set it correctly.
Website is : beautymag.tips
Any suggestions?
Thank you.
Please Log in or Create an account to join the conversation.
- Martin Rother
-
- Offline
- New Member
- Posts: 9
imgur.com/2Gv6mm7
There are no more open graph tag generating plugins installed. og:image is still missing even with disabled jch optimized.
Joomla 3.5, K2 2.7
item.php: only order of a few sections changed.
view.html.php is original
// Set Facebook meta data
if($params->get('facebookMetatags', '1'))
{
$document = JFactory::getDocument();
$uri = JURI::getInstance();
$document->setMetaData('og:url', $uri->toString());
$document->setMetaData('og:title', (K2_JVERSION == '15') ? htmlspecialchars($document->getTitle(), ENT_QUOTES, 'UTF-8') : $document->getTitle());
$document->setMetaData('og:type', 'article');
$facebookImage = 'image'.$params->get('facebookImage', 'Small');
if ($item->$facebookImage)
{
$basename = basename($item->$facebookImage);
if (JFile::exists(JPATH_SITE.'/media/k2/items/cache/'.$basename))
{
$image = JURI::root().'media/k2/items/cache/'.$basename;
$document->setMetaData('og:image', $image);
$document->setMetaData('image', $image);
}
}
$document->setMetaData('og:description', strip_tags($document->getDescription()));
}
('facebookImage', 'Small')
Thank you
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
The image is retrieved propery -> developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fbeautymag.tips%2Fnailsh%2Fitem%2F67-dye-another-day
@Martin Are og tags enabled in your site?
Also I will need a link to your site.
Please Log in or Create an account to join the conversation.
- Martin Rother
-
- Offline
- New Member
- Posts: 9
Medienportal Grimma
Example
Thank you
Please Log in or Create an account to join the conversation.
- Dimitris
-
Topic Author
- Offline
- New Member
- Posts: 6
Thank you
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
@Dimitris , make sure that the image size you have chosen meets OG's requirements.
developers.facebook.com/docs/sharing/best-practices
Please Log in or Create an account to join the conversation.
- Martin Rother
-
- Offline
- New Member
- Posts: 9
Martin Rother wrote: og:image is still missing even with disabled jch optimized.
I've also tried to change the ordering of system plugins.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Please Log in or Create an account to join the conversation.
- Martin Rother
-
- Offline
- New Member
- Posts: 9
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Please Log in or Create an account to join the conversation.
- Martin Rother
-
- Offline
- New Member
- Posts: 9
medienportal-grimma.de
JCH and minifying is active, at this time. I have also tried with disabled admin tools plugin, but admin tools does not affect the html code, i assume.
Thank you
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Which extension are you using for this functionality?
Can you temporarily (in a dev site of course) disable this setting?
Please Log in or Create an account to join the conversation.