Bug 11602

Summary: Fix localcover display
Product: Koha Reporter: Nicholas van Oudtshoorn <vanoudt>
Component: OPACAssignee: Nicholas van Oudtshoorn <vanoudt>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: minor    
Priority: P5 - low CC: chris, f.demians, hector.hecaxmmx, julian.maurice, kyle, liz
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Adds a CSS class of thumbnail to local covers. Don't show the 1px "No image found" image (since we'll usually try another image provider).
Version(s) released in:
Circulation function:
Attachments: Add a class to local thumbnails and don't show 1px no-image-found
[SIGNED-OFF]BUG 11602: [ENH] Fix localcover display Adds a css class of thumbnail to local covers
[PASSED QA] BUG 11602: [ENH] Fix localcover display

Description Nicholas van Oudtshoorn 2014-01-23 05:26:12 UTC
I'm busy playing around with updating to the nice new bootstrap theme. We use google jackets most of the time, but have some localcovers stored too. 

I want to style the localcover imgs the same as any other bookmark. Ideally, they need a thumbnail class. But the 1px image that is returned causes (potentially, at least in my case) things like empty borders.

Could the Locacovers.js function be modified to
a) include a class of thumbnail for the image
b) not insert the image when it is 1px in size.

The following function would do that...

    /**
     * Search all:
     *    <div title="biblionumber" id="isbn" class="openlibrary-thumbnail"></div>
     * or
     *    <div title="biblionumber" id="isbn" class="openlibrary-thumbnail-preview"></div>
     * and run a search with all collected isbns to Open Library Book Search.
     * The result is asynchronously returned by OpenLibrary and catched by
     * olCallBack().
     */
GetCoverFromBibnumber: function(uselink) {
        $("div[id^=local-thumbnail],span[id^=local-thumbnail]").each(function(i) {
            var mydiv = this;
            var message = document.createElement("span");
            $(message).attr("class","no-image");
            $(message).html(NO_LOCAL_JACKET);
            $(mydiv).append(message);
            var img = $("<img />").attr('src',
                '/cgi-bin/koha/opac-image.pl?thumbnail=1&biblionumber=' + $(mydiv).attr("class"))
                .load(function () {
                    this.setAttribute("class", "thumbnail");
                    if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth == 0) {
                        //IE HACK
                        try {
                            $(mydiv).append(img);
                            $(mydiv).children('.no-image').remove();
                        }
                        catch(err){
                        };
                    } else if (this.width > 1) { // don't show the silly 1px "no image" img
                        if (uselink) {
                            var a = $("<a />").attr('href', '/cgi-bin/koha/opac-imageviewer.pl?biblionumber=' + $(mydiv).attr("class"));
                            $(a).append(img);
                            $(mydiv).empty().append(a);
                        } else {
                            $(mydiv).empty().append(img);
                        }
                        $(mydiv).children('.no-image').remove();
                    }
                })
        });
    }
Comment 1 Nicholas van Oudtshoorn 2014-05-15 05:40:06 UTC Comment hidden (obsolete)
Comment 2 Héctor Eduardo Castro Avalos 2015-12-03 02:43:03 UTC Comment hidden (obsolete)
Comment 3 Katrin Fischer 2015-12-03 16:04:34 UTC
Created attachment 45364 [details] [review]
[PASSED QA] BUG 11602: [ENH] Fix localcover display

Adds a css class of thumbnail to local covers.
Don't show the 1px "No image found" image
(since we'll ususally try another image provider)

Signed-off-by: Hector Castro <hector.hecaxmmx@gmail.com>
Box with "No cover image availabe" fixed when syspref OPACLocalCoverImages
set to display

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 4 Katrin Fischer 2015-12-03 16:06:54 UTC
I see 2 sides on this: 
- It makes local covers behave more like the other cover services, showing the standard 'no-image'. (consistency)
- It means a change to existing installations, but the newly showing image can be easily hidden with CSS... so not sure this should stop this.
Comment 5 Kyle M Hall (khall) 2015-12-04 16:13:39 UTC
Patch pushed to master.

Thanks Nicholas!
Comment 6 Julian Maurice 2015-12-07 10:37:21 UTC
Patch pushed to 3.22.x, will be in 3.22.1
Comment 7 Frédéric Demians 2015-12-07 13:14:00 UTC
This patch has been pushed to 3.20.x, will be in 3.20.7.
Comment 8 Nicholas van Oudtshoorn 2015-12-22 03:16:50 UTC
Thanks everyone - great to have contributed to Koha! :-)