About

Image Proxy plug-in serves three different purposes:

  • Performs remote re-directs -- transparently to the UI -- so as to facilitate better image caching in more browsers
  • Performs image look-ups by thumb-nail URLs or ISBNs behind the scenes. If the client looks up images itself using ISBNs taken from the record, shifting of images may occur as more results - and more ISBNs - come in from Pazpar2 for a given record/hit. The image proxy provides the browser with just one URI for an image for a record, no matter how many ISBNs or thumburls the record has, thus making it possible for the browser to cache and reuse the first image found for the record.
  • Caches images for faster retrieval

Protocol

The plug-in is invoked from the UI by the command 'imageproxy'. It can be called with a complete URL or with a record ID.

In the first case, it will simply request the image by the provided URL.

In the second case, the client must supply a sub-element name to look for images by. There are two options: 'usefield=md-isbn' or 'usefield=md-thumburl'.

In case of 'md-isbn' the plug-in will look for a cover image on Open Library using a random IBSN number from the record identified by the recid.

The plug-in will also need a size argument, which can be 'S', 'M' or 'L'.

In case of 'md-thumburl' the plug-in will use the address from a random 'md-thumburl' element in the record identified by the recid.

In any of these cases, the plug-in will make the request, follow up to one i redirect, cache the image on the session, and return the image to the client.

The plug-in will in other words return binary data.

Examples:

 
  Look-up by URL:
  /service-proxy/?command=imageproxy&imageuri=http://covers.openlibrary.org/b/isbn/0345427653-M.jpg
  
  Look-up by ISBN - small cover page image:
  /service-proxy/?command=imageproxy&recid=title-complete%20star%20wars...of%20the%20jedi&usefield=md-isbn&size=S 
 
  Look-up by thumbnail URL:
  /service-proxy/?command=imageproxy&recid=title-complete%20star%20wars...of%20the%20jedi&usefield=md-thumburl
   

Configuration

This plug-in is configured in service-proxy.properties or equivalent.

Registration

Plugin class is registered with the following (name is arbitrary):

plugins.imageproxy = com.indexdata.serviceproxy.plugins.ImageProxyPlugin

Usage in chain

ImageProxy is a stand-alone plug-in. It will return a binary response.

For example:

chains.imageproxy = imageproxy

Mandatory properties

# The URI at which to find cover images by ISBN and size
imageproxy.OPEN_LIBRARY_IMAGE_URL = http://covers.openlibrary.org/b/isbn/${isbn}-${size}.jpg

Optional properties

imageproxy.CACHE_ON_SERVER = true     # Whether the image should be cached on the server
                                      # (on the users HTTP session)
                                      # Default: true
imageproxy.CACHE_IN_BROWSER = true    # Whether the server should attempt to have the
                                      # browser cache the image. Actual caching is
                                      # browser dependent.
                                      # Default: true
imageproxy.CACHE_MISSING_IMAGE = true # Whether the server should also cache missing 
                                      # images (the noimage.gif). This would make no-images
                                      # faster but also implies that the plug-in gives up
                                      # finding the image at the first try.
                                      # Default: false 
imageproxy.CONNECTION_TIMEOUT = 5000  # Milliseconds to wait for a connection to the
                                      # image server in question before aborting
                                      # Default: 5000
imageproxy.SO_TIMEOUT = 5000          # Milliseconds to wait for a read operation 
                                      # to get the image from the server before aborting
                                      # Default: 5000