Graham
Nightmares This is the updated code for facebook og tags
I have tested this on one of my own blogs and it works although
facebook may have old versions of your share data cached and it will be up to you to get this reset
https://developers.facebook.com/tools/debug/sharing/batch/
This will only work on blogs that are output by xtscript and have a twig template file
The script creates AUTOMATIC facebook og meta tags using the posts title text content canonical URI and the FIRST image found in the post
I have already updated this on your site nightmareclick
This needs to go in your blog twig just below the
{% elseif view == 'entry' %} Line
<!--og_tags={{ data.post.title|replace({('$'):'$',('('):'('})|raw }}||{{data.post.content|striptags|trim|replace({('$'):'$',('('):'(',('"'):'"', ('\n'): ' ', ('\r'): ''})[:300]|raw}}||{{data.post.content|split('<img')[1]|split('src="')[1]|split('"')[0]}}-->
Copy code
Here is the actual xtscript code it needs it needs to be inserted after the blog has been assigned to a xtscript variable ( this expects it to be $blog )
# FB OG TAGS
get __xtblog_entry
if not $__xtblog_entry or not $blog
var $fb_og ={{
<meta content="DEFAULT TITLE" property='og:title' />
<meta content="SITE DESCRIPTION (max 300 chars)" property='og:description' />
<meta content='<xt:url/>' property='og:url' />
<meta content='website' property='og:type' />
}}
goto @skip_og
endif
var $og_tags_s = call strpos $haystack=$blog;$needle=og_tags=
var $og_tags_s = ($og_tags_s+8)
var $og_tags_e = call strpos $haystack=$blog;$needle=-->;$offset=$og_tags_s
var $og_tags = call substr $val=$blog;$start=$og_tags_s;$length=($og_tags_e-$og_tags_s)
var $og_title_s = 0
var $og_title_e = call strpos $haystack=$og_tags;$needle=||;$offset=$og_title_s
var $og_title = call substr $val=$og_tags;$start=$og_title_s;$length=($og_title_e-$og_title_s)
var $og_descr_s = ($og_title_e+2)
var $og_descr_e = call strpos $haystack=$og_tags;$needle=||;$offset=$og_descr_s
var $desc_len = ($og_descr_e-$og_descr_s)
var $og_descr = call substr $val=$og_tags;$start=$og_descr_s;$length=$desc_len
if $desc_len >= 300
var $spc=call chr $val=32
var $lstspc=call strrpos $haystack=$og_descr;$needle=$spc
var $og_descr= call substr $val=$og_descr;$start=0;$length=$lstspc
endif
var $og_img_s = ($og_descr_e+2)
var $og_img_e = call strpos $haystack=$og_tags||;$needle=||;$offset=$og_img_s
var $og_img = call substr $val=$og_tags;$start=$og_img_s;$length=($og_img_e-$og_img_s)
var $fb_og = {{
<meta content='<xt:canonical_uri/>' property='og:url' />
<meta content='article' property='og:type' />
<meta content="$og_title" property="og:title" />
<meta content="$og_descr" property="og:description" />
<meta content='$og_img' property='og:image' />
}}
@skip_og
Copy code you then need to add this to the
<head> area of the blog page using text editor