<%
' This code is free and is as is. No warranties express or impled... yadda yadda yadda.
' If you like it and want to express a thank you, consider buying something off the www.fitandgiggles website
' If you use it, feel free to send a thank you e-mail to caryevans2000@yahoo.com
' This code assumes you are using .jpg images for both the thumbnails and fullsize pictures. If you are
' using .gif then you will have to change it everywhere in the code.
' Thumbnails share the same name as your original with a common ending.
' e.g. Faimily-01.jpg - would be the thumbnail
' Family.jpg - would be the large image
' this is legacy crap from version 1.0 - ignore it
thumbsPerPage = 99999 ' Number of thumbnails to display on the page
thumbsPerRow = 4 ' Number of thumbnails to display per row - surprised
thumbIdentifier = "-01.jpg" ' The common string ending for all thumbnail images.
' You should not need to change any ASP code in this section below here.
pgURL = Request.ServerVariables("SCRIPT_NAME") 'the name of this page eg. default.asp
pgName = Right(pgURL, len(tt) - InStrRev(tt, "/")) ' The current page's name so you can rename the file
page = request.queryString("page") 'This is the page you are on, used for paging. Eg. page 1, 2, 3
if page = "" then page = 1 'If no page # exists, set to 1
img = Request.querystring("img") 'Large image to display if they clicked a thumbnail
pgmode = Request.querystring("pgmode")
' Determine which image to start / end at based upon paging and thumbsPerPage
first = ((page-1) * thumbsPerPage)
last = (page * thumbsPerPage)-1 'We do minus 1 here since we are using an array... array starts at 0 vs 1
' get the current folder location
strPathInfo = Request.ServerVariables("SCRIPT_NAME")
strPhysicalPath = Server.MapPath(strPathInfo)
set objFSO = CreateObject("Scripting.FileSystemObject")
set objFile = objFSO.GetFile(strPhysicalPath)
set objFolder = objFile.ParentFolder
set objFolderContents = objFolder.Files
' Count total number of thumbnails
totalImages = 0
For each objFileItem In objFolderContents
if inStr(LCase(objFileItem.Name),thumbIdentifier) then
totalImages = totalImages + 1
end if
next
'Limit last to totalImages so array does not go out of range.
if last > totalImages then last = totalImages
'Array starts at 0 vs. 1 so we need to offset this by 1 exception last image can't be > than total # of iamges
lastDisplay = last + 1
if lastDisplay > totalImages then lastDisplay = totalImages
' Create an array to put all the images in so that we can do paging
dim arrayOfThumbs()
ReDim arrayOfThumbs(totalImages)
imageList =""
i = 0
k = 0
' Populate the array with the images
For each objFileItem In objFolderContents
' only display the thumbnails - the images that have the ending defined in the thumbIdentifier variable at top of page
if inStr(LCase(objFileItem.Name),thumbIdentifier) then
'Isolate the image name so that we can create a link to the large version. This strips off the ending e.g. -01.jpg
image = split(objFileItem.Name, thumbIdentifier)
' Populate array
arrayOfThumbs(i)= "
" & vbCrLf
imageList = imageList & chr(34) &image(0) & ".jpg" & chr(34) & ","
if (i = 0) then defaultImage = image(0) & ".jpg"
i = i + 1
k = k+1
end if
next
%>
<%
' This is where the thumbnail images get written
response.write("")
'If there is no image on URL, show the thumbnail page
for j = first to last
response.write(arrayOfThumbs(j))
next
response.write("
")
response.write("")
%>