<![CDATA[ custom table, field "images", comma separated string -> output - My Forums]]> https://forums.modx.com/thread/?thread=102583 <![CDATA[custom table, field "images", comma separated string -> output]]> https://forums.modx.com/thread/102583/custom-table-field-images-comma-separated-string---output#dis-post-552737
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.

[[!migxLoopCollection?
    &packageName=`myPackageName`
    &classname=`myClassname`
    &tpl=`myChunk`
    &sortConfig=`[{"sortby":"RAND()"}]`
    &limit=`25`
    &outputSeparator=`,`
    &where=`{"id:=":"[[+id]]"}`
]]

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:

/uploads/user_1/image1.png,/uploads/user_1/image2.jpg 


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.

]]>
profilneurotiker Jul 23, 2017, 12:09 PM https://forums.modx.com/thread/102583/custom-table-field-images-comma-separated-string---output#dis-post-552737
<![CDATA[Re: custom table, field "images", comma separated string -> output]]> https://forums.modx.com/thread/102583/custom-table-field-images-comma-separated-string---output#dis-post-553108
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!]]>
profilneurotiker Aug 09, 2017, 07:20 PM https://forums.modx.com/thread/102583/custom-table-field-images-comma-separated-string---output#dis-post-553108
<![CDATA[Re: custom table, field "images", comma separated string -> output (Best Answer)]]> https://forums.modx.com/thread/102583/custom-table-field-images-comma-separated-string---output#dis-post-552783
$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]]`]]
]]>
Bruno17 Jul 25, 2017, 04:36 PM https://forums.modx.com/thread/102583/custom-table-field-images-comma-separated-string---output#dis-post-552783