Access Folder of Images (of type CMS.File) under certain page

Farah El Agha asked on January 23, 2018 15:41

Hello, I have a page of type "Timeline", which has text, title and date, I want to add under each page a folder of images Timeline1> images > image1, image2, image3, .. now I am trying to access these images (trying to get their path to associate it with an img src)to display them in my page transformation, but it's not working, the images are of type CMS.File, how can I achieve that? and would I have to use a repeater withing the transformation?

Recent Answers


Naresh Ede answered on January 23, 2018 16:54

Hi Farah ,

You can use repeater with query data source.

And this query will be like this select AttachmentName,AttachmentGUID from CMS_Attachment A,CONTENT_File C where A.AttachmentGUID=C.FileAttachment

And this transformation should work <img src="/cms/getattachment/{%AttachmentGUID %}/{%AttachmentName%}.aspx" />

0 votesVote for this answer Mark as a Correct answer

Farah El Agha answered on January 23, 2018 16:58

Thank you Naresh, but please note that images are not attached to my page, but only located in a child folder "images", so I dont this gonna work.

0 votesVote for this answer Mark as a Correct answer

Naresh Ede answered on January 23, 2018 18:26

sorry Farah, No need to write custom queries. You can use normal repeater with your path should be Images folder and Page Type should be CMS.File

And you can use this transformation <img src="/cms/getattachment/{%FileAttachment%}/{%DocumentName%}.aspx"><br>

Hope this should solve your problem

If it works , please mark this as correct answer.

ThankYou

Naresh Ede

0 votesVote for this answer Mark as a Correct answer

Farah El Agha answered on January 23, 2018 18:48 (last edited on January 23, 2018 19:02)

okay but my problem was how to get the path in of the Images folder from within the transformation? Also for the image src: < img src="/cms/getattachment/{%FileAttachment%}/{%DocumentName%}.aspx"> this is not getting the image, there is a problem with the path

0 votesVote for this answer Mark as a Correct answer

Naresh Ede answered on January 23, 2018 19:07

Farah, don't bother about physical path in transformation , use the given above transformation as it is, that will get your file on the fly based the file guid and name. So only you should configure the repeater web part path property(images folder in content tree), page type and transformation(given above).

Sorry if I'm wrong.

0 votesVote for this answer Mark as a Correct answer

Farah El Agha answered on January 23, 2018 19:21

well yes it seems like we need to specify the path of the Images folder to get only the images below this page, it would have to look like this "currentpath/Images/%", but I dont know how to get this? Also for the image source, it seems like its wrong because it is not returning the image (even when I set a static path to the repeater), the images look like small broken image icons, and when I try to put the img src in the browser it returns "The resource cannot be found." error

0 votesVote for this answer Mark as a Correct answer

Farah El Agha answered on January 26, 2018 13:43

Hi, I still could'nt find the correct function to catch the images path, any updates?

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.