We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18809
    • 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.
      My Proudly Powerd By Modx site - http://irresistiblemt.in smiley Its simple site but its made in best CMS.
      • 42046
      • 436 Posts
      I haven't used it before but ContentVampire extracts image links from the content area and outputs to a JSON TV. Could possibly be used for this purpose.

      http://modx.com/extras/package/contentvampire
        • 18809
        • 109 Posts
        Let me try this and then will get back to you. smiley
        Thanks
          My Proudly Powerd By Modx site - http://irresistiblemt.in smiley Its simple site but its made in best CMS.
          • 18809
          • 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
            My Proudly Powerd By Modx site - http://irresistiblemt.in smiley Its simple site but its made in best CMS.
          • 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]]
              Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

              Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
              • 18809
              • 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
                My Proudly Powerd By Modx site - http://irresistiblemt.in smiley Its simple site but its made in best CMS.