Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2019-06-10 13:37:07

Gallex
Member
Registered: 2006-10-08
Posts: 1,289

article image field as facebook meta property

is it possible to achieve?

Offline

#2 2019-06-10 15:04:17

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,137
GitHub

Re: article image field as facebook meta property

Edit: ignore this, use colak’s example below.

textpattern.tips/implementing-facebook-services-on-textpattern-articles-via-fbml

Last edited by gaekwad (2019-06-11 10:53:57)

Offline

#3 2019-06-10 15:44:14

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: article image field as facebook meta property

Gallex wrote #318439:

is it possible to achieve?

Hi Gallex

Check how we went about it for facebook (og standard) and twitter starting on line 71 on github. You can adapt that code by using <txp:custom_field name="article_image" />.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#4 2019-06-10 17:52:08

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: article image field as facebook meta property

FYI Facebook’s FBML was discontinued years ago. Colak’s example is the way to go.

Offline

#5 2019-06-11 10:23:56

towndock
Member
From: Oriental, NC USA
Registered: 2007-04-06
Posts: 329
Website

Re: article image field as facebook meta property

Example:

<meta property=“og:image” content=“https://yourdomain.com/img/<txp:custom_field name=“article_image” />.jpg” />

Offline

#6 2019-06-11 11:09:27

Gallex
Member
Registered: 2006-10-08
Posts: 1,289

Re: article image field as facebook meta property

towndock wrote #318446:

Example:

<meta property=“og:image” content=“https://yourdomain.com/img/<txp:custom_field name=“article_image” />.jpg” />

you are using it like this?

Offline

#7 2019-06-11 11:33:30

Gallex
Member
Registered: 2006-10-08
Posts: 1,289

Re: article image field as facebook meta property

colak wrote #318442:

Hi Gallex

Check how we went about it for facebook (og standard) and twitter starting on line 71 on github. You can adapt that code by using <txp:custom_field name="article_image" />.

thank’s colak! i start to investigate it.

first issue:
p. this: <meta property="og:url" content="<txp:site_url /><txp:page_url />" />
outputs this: <meta property="og:url" content="https://www.mysite.ee//portfolio/">

look, extra slash before section name

Last edited by Gallex (2019-06-11 11:34:13)

Offline

#8 2019-06-11 11:44:59

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: article image field as facebook meta property

Whoops I recently changed that in order to make it more generic. You can change it by using <txp:permlink /> for individual articles and http://www.yoursite.tld<txp:page_url /> for section landing pages. It all depends of course on how you use your site. The example allows only for sections and individual pages and has not been tested with categories author urls.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#9 2019-06-11 16:45:21

towndock
Member
From: Oriental, NC USA
Registered: 2007-04-06
Posts: 329
Website

Re: article image field as facebook meta property

Gallex wrote #318447:

you are using it like this?

Yes, for many years. It of course presumes that your image directory is “img”.

Example article with Facebook & Twitter meta:
https://towndock.net/shippingnews/s-v-misto

Offline

#10 2019-06-12 09:22:04

Gallex
Member
Registered: 2006-10-08
Posts: 1,289

Re: article image field as facebook meta property

in article pages colak solution
<txp:if_description><meta property="og:description" content="<txp:meta_description format="" />" /></txp:if_description>
works well if user has inserted something into article’s description field, if not, no facebook meta description.

for google i use rah_metas plugin for that:

<txp:if_description><txp:meta_description /><txp:else />
<txp:rah_metas description_from="body" description_replacement="1" /></txp:if_description>

tried to implement it into facebook’s meta too, but with no success:

<txp:if_individual_article>
<meta property="og:description" content='<txp:rah_metas description_from="body" description_replacement="1" />' />
</txp:if_individual_article>

is it possible to use it, what you think?

Offline

#11 2019-06-12 10:03:53

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: article image field as facebook meta property

Hi Gallex,

re description, you can use:

<txp:if_description>
<meta property="og:description" content="<txp:meta_description format="" />" />
<txp:else />
<meta property="og:description" content="<txp:excerpt />" />
</txp:if_description>

Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#12 2019-06-12 13:00:46

Gallex
Member
Registered: 2006-10-08
Posts: 1,289

Re: article image field as facebook meta property

Gallex wrote #318457:

<txp:if_individual_article> <meta property="og:description" content='<txp:rah_metas description_from="body" description_replacement="1" />' /> </txp:if_individual_article>

just show you, how facebook displays the code above:

<meta name="description" content="this is description text from article body..." />

Offline

Board footer

Powered by FluxBB