-
- 109 Posts
Hello,
I want post thumbnail image to load automatically from my article. Just like featured image of Wordpress, to fetch first(or any) image from the post. So I don;t have to add thumbnails for each post. And its best when I import articles from Wordpress blog xml and then I don;t have to add post thumb to my hundreds of imported articles.
My Current setting is this -
<img src="[[phpthumbon? &input=`[[+tv.PostThumb]]` &options=`&w=610&h=300&zc=1&q=80&aoe=1`]]" alt="[[+pagetitle]] pictures" title="[[+pagetitle]]">
Hope you understand what I want to write.
-
- 109 Posts
Let me try this and then will get back to you.
Thanks
-
- 109 Posts
I placed the TV in my template for testing and this is the result -
{"images":[{"iteration":0,"src":"assets\/Uploads\/10473641_345679162258650_4404488938931437884_n.jpg","alt":"","title":null}]}
How to use this JSON to work with my TV ?
I want like this
assest/uploads/image123.jpg
Create a snippet "getFirstImage" with something like this:
$data = $modx->fromJSON($input);
if (is_array($data) && isset($data['images']) {
$img = first($data['images']);
return $img['src'];
}
return 'Oops, no image found';
and then in your template, add [[*myTemplateVariable:getFirstImage]]
-
- 109 Posts
Hello,
I tried this :
[[*vampireValues:getFirstImage]]
vampireValues is contentvampire extras tv name as mentioned in installation.
I am getting
Parse error: syntax error, unexpected '{' in C:\wamp\www\modx-2.3.1-pl\core\cache\includes\elements\modsnippet\46.include.cache.php on line 3