RandomImage

Gets a random image from a folder of files, passed as an unMapPathed (HTML) folder.
Tries 10 times to read an image (gif, jpg and png only), returns blank if not

CodeFunctionName
What is this?

Public

Tested

Original Work
Function RandomImage(Path_UnMapPathed)
' Gets a random image from a folder passed through HTML folder
' Needs FilesIn, CutString3
RandomImage = ""
ServerFolder = Server.MapPath(Path_UnMapPathed)
AllFees = FilesIn(Path_UnMapPathed, "|")
Cou = Len(AllFees) - Len(Replace(AllFees, "|" ,""))
If Cou = 0 Then Exit Function
DoCo = 0
Do
DoCo = DoCo + 1
If DoCo > 10 Then Exit do ' Try to find random image 10 times only
Randomize
GetRnd = Int((Cou * Rnd) + 1)
F1 = CutString3(AllFees, GetRnd , "|")
F2 = UCase(Right(F1,4))
If F2 = ".JPG" Or F2 = ".GIF" Or F2 = ".PNG" Then Exit Do
Loop
RandomImage = F1
End Function

Path_UnMapPathed

Views 3,529

Downloads 1,345

CodeID
DB ID