You could try something like the following. It loops through each of the case study images, combining their urls together and then trimming the end comma:
@if (childPage.HasValue("portfolioImages"))
{
var caseStudyImagesList = childPage.portfolioImages.Split(new [] { "," }, StringSplitOptions.RemoveEmptyEntries);
var caseStudyImagesCollection = Umbraco.Media(caseStudyImagesList);
var outputStr = string.Empty;
foreach (var caseStudyImage in caseStudyImagesCollection)
{
outputStr += string.Format(" , {0}", caseStudyImage.Url);
}
@outputStr.TrimEnd(" , ")
}
Comma separated output
Hi,
The code below almost work but I need it to separate the output with a comma like this:
/media/1005/test_image_645_1.jpg , /media/1006/test_image_645_2.jpg
At the moment the output is without a comma like this:
/media/1005/test_image_645_1.jpg /media/1006/test_image_645_2.jpg
Does anyone have a simple solution?
Thanks in advance!
// René
Hi Rene,
With this code you should be good. :-)
Hope this helps,
/Dennis
Hi René,
You could try something like the following. It loops through each of the case study images, combining their urls together and then trimming the end comma:
Hope that helps.
Thanks, Dan.
Hi Dennis and Dan
Both solutions worked for me. Thank you!
Have a nice weekend.
// René
Hi Dan
I just found one little problem regarding your solution. Because the output is beginning with a comma like below:
,/media/1005/test_image_645_1.jpg,/media/1006/test_image_645_2.jpg
Is it possible to remove the comma in the beginning?
Thanks!
// René
Ah of course. Trying changing your code to use the following line instead of TrimEnd():
Thanks, Dan.
Ahh that was very simple...I am still learning thanks to guys like you. :-)
Thanks!
is working on a reply...