Quote from: markh at Jun 06, 2015, 11:43 PMhttp://onsitenow.co.uk/modx/how-to-get-the-first-image-from-a-blog-post-for-the-open-graph-protocol-html-head-tags/
https://gist.github.com/govza/4757102
http://modx.com/extras/package/getimagesfromhtml
Thank you very much Mark. I almost got what I what. Just a little problem here.
I am using this snippet -
$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;
When I use it for a document, its working but this call
[[getFirstImageInResource]]
generating url
ttp://imagepath/image.jpg instead of
http. I have to put h before snippet call to make it working. so its like
h[[getFirstImageInResource]]
The main problem facing -
When I use this
[[++site_url]][[getFirstImageInResource]]
in my Article extra's container, it only generates default image. I want it to generate image from the article to make it featured image.
I hope you understand what I want to say.
Aslo tell me how can I use this to crop image with phpthumbof?