Open Graph protocol integration
I want to do the integration, is there an easy way to get the first photo of a page from the template?
the idea is to be able to easily add these META:
<meta property="og:title" content="Example title of article">
<meta property="og:site_name" content="example.com website">
<meta property="og:type" content="article">
<meta property="og:url" content="http://example.com/example-title-of-article">
<meta property="og:image" content="http://example.com/article_thumbnail.jpg">
<meta property="og:description" content="This example article is an example of OpenGraph protocol.">
Cheers
Semantic Markups
Comments
Log in or create an account to post a comment.
Re: Open Graph protocol integration
The
file_linktable tracks all used files of a page.The
external_linktable tracks analog external images.How and where you want determine the image you wanna use? Guess this is the main question, the rest is just code. So we can for example parse / set a file_id as metadata into the page table.
This can be integrated in the properties or attachments handler. On the other hand you can add a additional
ogtable and handler, totally independent from the core application./theme/_common/_header.php
$tpl->og_title = $this->page['title']; $tpl->og_type = 'article'; $tpl->og_url = $this->href('', $this->tag, null, null, null, null, null, true); $tpl->og_image = $this->page['image']; $tpl->og_description = $this->page['description'] ?? null;/theme/_common/_header.tpl
Re: integration with The Open Graph protocol
Thank you very much for your help.
But I wanted him to take the first external link of the article and leave it in og_image
I hope that now the idea is understood
Greetings
Re: Open Graph protocol integration
my quick and easy solution by adding a search in the file /theme/_common/_header.php
$tpl->og_title = $this->page['title']; $tpl->og_type = 'artículo'; $tpl->og_url = $this->href('', $this->tag, null, null, null, null, null, true); preg_match('#\(http(.*?)\)#', $this->page['body'], $match); $tpl->og_image = "http".$match[1]; $tpl->og_description = $this->get_description();I hope that someone will serve you too, as it is more comfortable to put the automatic photo from the article.
Greetings and thanks for the help.
Re: Open Graph protocol integration
We working on the topic, but it will take some time to read the sources, look how it is done elsewhere, evaluation, think about it, test and rethink it again.
I already thought about a short time hack, until we have a general solution:
A temporary hack for the external image (Does not update the image once written!):
The goal is to parse it only once when the page is saved and store the result in the page table, to load the image with
$this->page.Now we have two cases, you might have an external image as well as an attached image.
https://example.com/article_thumbnail.jpgfile:/article_thumbnail.jpgAdditionally we want a flexible solution for the description, it can be a text snippet from
$this->page['body']or just$this->page['description'].I already looked how it is done in MediaWiki and DokuWiki. None of them deal with external images.
And we want some configurable parameters for the description and the image output.
For instance we could add an option in the attachment handler to chose which image should be used.
And or an entire new handler or handler section can be added, storing all related data in an extra table [text_extract, image, other values...].
[... more edits upcoming]
Tools:
Re: Open Graph protocol integration
you are absolutely right, it is not the best solution since I do not know the whole structure of wacko.
I have no problem in waiting for a better solution from the team, what I did is just a proof of concept to see the viability of my idea.
Greetings