How to refer uploaded files in Koha ILS

During the last Koha ILS Users Philippines Google Meet (July 18, 2020), Geffy Pen from University of Rizal System asked during the Google meet if we can refer image sources from Google Drive when editing various OPAC Global System Preferences like opacheader and OPACMainUserblock. I honestly does not have an answer to it as I haven’t tried referencing images in Google Drive when customizing the Koha ILS OPAC. I instead answered her to just instead upload the image file (jpg, png, etc.) into Koha ILS via Tools > Upload any file (/cgi-bin/koha/tools/upload.pl). Uploading any files has been in Koha ILS for quite some time (3.22 released November 2015). Using this way to refer to uploaded files will ease any migration nightmares since the uploaded file is already included in the Koha ILS backup mechanism. Note though that to be able to upload this module, there is a need to tweak the Koha ILS instance’s configuration, you can refer to the blog of our friend from India Vimal to be able to enable this (following nos. 1-4). For the procedure on how to go on the with the process, please see images below.

Take note that “Allow public downloads” should be checked or else this particular file we are uploading won’t show up if we call it via “img src” later. As of 19.11.x, we won’t be able to change the setting for allow public downloads

Once uploaded, we will be presented with a page similar below. What we’re interested here is the hashvalue, which we will append to “/cgi-bin/koha/opac-retrieve.pl?id=”.

So for our particular case, we have a relative URL “/cgi-bin/koha/opac-retrieve-file.pl?id=da1afe6be11ad47fce0ce5616c3a56a1” which is what we will add to image source html tag <img src>. We can now reference this image by the following html tag:

<img src="/cgi-bin/koha/opac-retrieve-file.pl?id=da1afe6be11ad47fce0ce5616c3a56a1" alt="Our banner">

We can add this this into our html codes for further customization of our OPAC, in my example below, Koha ILS’s opacheader.

Save our OPAC preferences, and voila! Our uploaded big banner is now there in our opacheader or banner.

You can certainly upload a banner that fits your library but for the purpose of demonstration, I uploaded a big banner for this exercise.

If your library is uploading various images into the web server through FTP (File Transfer Protocol), you can use this method instead. As I’ve mentioned above, what we’ve uploaded through Koha upload (any) files could have been taken care of by Koha ILS default backup and restoring backups through koha default command will be a breeze.