- Posts: 9
COMMUNITY FORUM
Opengraph Image tag not being rendered
- Mark Fallon
-
Topic Author
- Offline
- New Member
I am using K2 Version 2.6.8.
The other Opengraph tags are rendered fine (url, title, description & type) but there is no og:image tag, even though the K2 item has an image set.
Any ideas?
Thanks
Mark
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Have you specified which image size you want to use?
This setting is located in K2's params.
Please Log in or Create an account to join the conversation.
- Mark Fallon
-
Topic Author
- 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.
- Mark Fallon
-
Topic Author
- Offline
- New Member
- Posts: 9
Another related question: If there is no image in the article, how can I set a default og:image src?
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Yes you can perform an if/else check in your template and if an image is not present you can use the setMetadata function docs.joomla.org/JDocument/setMetaData .
Please Log in or Create an account to join the conversation.
- Mark Fallon
-
Topic Author
- Offline
- New Member
- Posts: 9
I need to find the K2 file that sets the og:image tag so I can amend it. Have you any idea which file it is? I have searched through the file contents of the K2 folder to find "og:image" but no luck.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
You will lose all your changes when you update.
This has to be done via template overrides.
You need to check if the image is both set and present.
This post will help you on template overrides.
getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates
Please Log in or Create an account to join the conversation.
- Mark Fallon
-
Topic Author
- 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.
- Mark Fallon
-
Topic Author
- Offline
- New Member
- Posts: 9
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
You simply need to add a new metatag if an image is not present.
Please Log in or Create an account to join the conversation.
- Mark Fallon
-
Topic Author
- Offline
- New Member
- Posts: 9
I have done it the way you suggested instead and although being quite a hacky way, it does work.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
You get to keep your edits even if you update K2.
If you tried the other way you would have to backup and re-patch K2 after every update.
Please Log in or Create an account to join the conversation.
- Mark Fallon
-
Topic Author
- Offline
- New Member
- Posts: 9
Placing this code into a random place in a file that doesn't deal with the generation of the og meta tags, IS a hacky way of doing it.
It would make more sense to to edit the relevant code that generates the meta tags, in the relevant file (using a template override obviously), rather than just placing it in any old place in the item.php file.
But I suppose I like to keep my code neat and logical. Other people may not.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Some people help you with your project for free while other may don't.
Anyway it works like this.
Either hack core files or change item.php
No other file can be overriden.
I am locking the topic now.
Please Log in or Create an account to join the conversation.