SSRS External Images with Dynamic File Extensions

Viewed 1957

I have a report that needs to show images from a Windows folder on the server, which is working (see here ). Now, I am wondering how to get the report to pull images of differing file types, like jpg & tif. (I am using png by default). Is there a relatively easy way to do this? The image names with file extension are not in the SQL database.

EDIT: I entered this in the Custom Code block, from Daniel's help below.

Public Function GetImage(ByRef Filename As String) As String ' Full image path used for testing if it exists Dim ImagePath As String ImagePath = "\\GVSSERVER1\GVSServerD\Acclamare_Images\" + Filename ' Test to see if the file exists as a gif Try If System.IO.File.Exists(ImagePath + ".png") Return "file://" + ImagePath + ".png" ElseIf System.IO.File.Exists(ImagePath + ".jpg") Else Return "file://" + ImagePath + ".jpg" End If Catch ex As Exception Return "Hit an Error" End Try Return "Hit the end" End Function
When I run the report, it fetches the .jpg extension even though the image file is a png, and there isn't a jpg file for that item. Any idea on how to correct that?
EDIT 2: I wasn't having success with the updated custom code, but I could have been missing something, as I'm no expert with custom code. I found this question (see here) which is for a function. I tried it and it works, except for some reason .tif files don't display on the report. I installed Microsoft Picture Manager (from the Sharepoint exe download), but it still doesn't display the .tif files.

1 Answers
Related