output"> output" />
We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 35756
    • 166 Posts
    Hello there again!

    I'm trying to get the value of the fieldname "images" in a custom db, which holds the filename of uploaded images. It can be empty, a single filename or a comma-separated list of several filenames.


    With the above call I'm getting the desired value with the tpl "myChunk":

     <img src="[[+images]]" /> 

    But this is a comma-separated list, like this:


    So the source code looks like this:

     <img src="/uploads/user_1/image1.png,/uploads/user_1/image2.jpg" /> 

    I want to output the two images in a separate chunk. So I hoped the "&outputSeparator" attrtibute could help, but it doesn't. How can I achieve that? Do I have to edit the migxloopcollection-snippet? Any help is appreciated.

    This question has been answered by Bruno17. See the first response.

    • discuss.answer
      • 4172
      • 5,888 Posts
      try to create a snippet to create the imagelist like this:

      $images = explode(',',$modx->getOption('images',$scriptProperties,''));
      $output = array();
      foreach ($images as $image){
          if (!empty($image)){
              $output[] = '<img src="' . $image . '" />';
      return implode('',$output);

      and call it with

      [[!prepareImages? &images=`[[+images]]`]]

        you can buy me a beer, if you like MIGX


        • 35756
        • 166 Posts
        Hello Bruno!

        Thanks a lot again(!) for getting into my "problem" and helping me! You are the best!
        And sorry for the late "thank you" - real-life-jobs kept me busy during the last two weeks...

        The solution you posted is working, nice and thanks!

        I figured out that I can't use "pthumb" the "normal MODx-way" by using this

        	 [[!pthumb? &input=`[[+images]]` &options=`h=200` &toPlaceholder=`thumb`]] 

        but I guess it might be able by editing the "prepareImages-snippet".

        I'm gonna try to sort this out on my own...I hope! wink

        Kind regards to you!