I want the og:image metatag be populated automatically by the url of the first image in the *content of each page.
This is the code from Mike Nuttall
http://onsitenow.co.uk/modx/how-to-get-the-first-image-from-a-blog-post-for-the-open-graph-protocol-html-head-tags/
<?php
$content = $modx->resource->content;
if(preg_match("/src=\"(.*?)\"/",$content,&$matches)){
$img = substr($matches[1],1,strlen($matches[1]));
}
else {
$img = "assets/images/defaultImage.png";
}
return $img;
But when I try it on my site I get PHP parse error. My PHP knowledge is very basic, I looked up the preg_match
http://php.net/manual/de/function.preg-match.php, but am not sure about it.
Last error message was "Fatal error: Call-time pass-by-reference has been removed".
Can anyone help?