This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Fredrik Ampler
Posted Aug 24 - Read on Facebook

How can I read all files (photos) in a specific folder, and put them in an array?
I want something like:
imgArray = "images/*.*"
which would enable me to do
layer.image = imgArray[n]


Arron J Hunt

You can't, unless it's being hosted on a server and you use an Ajax call. you would have to do something like

imgNames = ["img1.png", "img2.png", "img3.png"]
dirName = "images/"

layer.image = "#{dirName}#{imgNames[n]}"

Fredrik Ampler

Thanks! So I guess putting the Framer files on a public dropbox folder doesn't enable me listing its subfolder content? I have to know each filename beforehand and do layer.image = "images/tulip.jpg" manually for each file I want to use?

Arron J Hunt

Right, javascript doesn't have the ability to read contents of a local directory unfortunately.

What I do is name my images in sequence, like "img1", "img2", img3" and then loop through them that way.

Fredrik Ampler

Great help, thanks!

Jonathan Lazarini

I dont whether it can help or not but I store my images in a folder(s) name them 1.png , 2.png, etc.. and then in my loop use the index.

layer.image = 'images/test/' + (layer.listIndex + 1) + '.png'

Arron J Hunt

Jonathan that was my suggestion above ;)

Read the entire post on Facebook