[Koha] images

Owen Leonard oleonard at athenscounty.lib.oh.us
Thu Jan 22 08:25:39 NZDT 2004


> > no image for a particular ISBN, you get a 
> > broken image.
> 
> With the right apache config, maybe you could use 
> an .htaccess file in 
> the images dir which says:
>    ErrorDocument 404 /path/to/some/file.png

I did a little investigation of apache config solutions... The disadvantage to 
the above system, as far as I can tell, is that it depends on having the image 
load directly in the browser, while what we want is the image to load inline 
with a page like opac-detail.pl.

A PHP solution was suggested to me in which the image tag point to a php file, 
passing the ISBN as a parameter.  The PHP  file then checks for the existence 
of the image, and if delivers it if found.  If not it delivers an alternate.  
Here's a snippet, with $img_location being the full path to the image file:

    $buffer = @file_get_contents($img_location);
	if($buffer){
    header('Content-Type: image/jpg');
    header('Content-Length: '.strlen($buffer));
    echo $buffer;
	}

Here's the documentation for the file_get_contents if that helps explain:

http://us4.php.net/manual/en/function.file-get-contents.php

I'm sure there's an easy Perl solution to match, but it's beyond my skills. If 
anyone wants to step up I'd certainly be grateful.

  -- Owen



More information about the Koha mailing list