Bug 7600 - Have book cover image script return single-pixel gif data
Summary: Have book cover image script return single-pixel gif data
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Tools (show other bugs)
Version: 3.8
Hardware: All All
: P5 - low normal (vote)
Assignee: Jared Camins-Esakov
QA Contact: Ian Walls
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-24 21:33 UTC by Owen Leonard
Modified: 2013-12-05 20:01 UTC (History)
2 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 7600: Return a single-pixel GIF when no local cover image exists (7.24 KB, patch)
2012-03-08 03:12 UTC, Jared Camins-Esakov
Details | Diff | Splinter Review
signed-off patch (7.27 KB, patch)
2012-03-19 08:35 UTC, Kristina Hoeppner
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Owen Leonard 2012-02-24 21:33:39 UTC
When you request a book cover image from Amazon which doesn't exist, the response isn't a 404 but a single-pixel GIF. This page describes ways in which developers can use this to have display of Amazon covers gracefully degrade:

http://www.oreillynet.com/pub/a/javascript/2003/10/21/amazonhacks.html

We use the client-side technique in Koha. I wonder if we couldn't do the same thing with the local covers? The hex dump of a single-pixel gif is tiny:

4749 4638 3961 0100 0100 8000 00ff ffff
0000 0021 f904 0100 0000 002c 0000 0000
0100 0100 0002 0244 0100 3b

Could that be converted to binary and returned in place of an error? For instance, line 103 of opac-image.pl, "warn "No image exists for $imagenumber" if $DEBUG;"

I'm guessing this would speed up loading the page since the browser spends a lot of time looking for cover images which don't exist.
Comment 1 Jared Camins-Esakov 2012-03-08 03:12:47 UTC Comment hidden (obsolete)
Comment 2 Kristina Hoeppner 2012-03-19 08:35:31 UTC
Created attachment 8254 [details] [review]
signed-off patch

The test of the proposed patch was successful in that the 404 error message is not shown anymore (in Firefox 10 it could only be seen in the "Net" tab in Firebug after a reload of the page).

The patch adds a tiny gif image and the placeholder "No cover image available" is not displayed. I saw that as a good sign to avoid too much information that doesn't really help the user.
Comment 3 Ian Walls 2012-03-19 21:26:02 UTC
Falling back to a 1 pixel gif seems pretty safe, and it's well implemented here.  This also opens the door for other default 'noimage' images down the road, should it ever come up.

Passed QA.
Comment 4 Paul Poulain 2012-03-20 16:01:38 UTC
* local cover is a 3.8 ENH, so setting version accordingly
* C4/Image.pm has 2 perlcritic failure before the patch, one after, good job ;-)