Bug 11602 - Fix localcover display
Summary: Fix localcover display
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: OPAC (show other bugs)
Version: master
Hardware: All All
: P5 - low minor (vote)
Assignee: Nicholas van Oudtshoorn
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-23 05:26 UTC by Nicholas van Oudtshoorn
Modified: 2017-06-14 22:11 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
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:


Attachments
Add a class to local thumbnails and don't show 1px no-image-found (1.67 KB, patch)
2014-05-15 05:40 UTC, Nicholas van Oudtshoorn
Details | Diff | Splinter Review
[SIGNED-OFF]BUG 11602: [ENH] Fix localcover display Adds a css class of thumbnail to local covers (1.78 KB, patch)
2015-12-03 02:43 UTC, Héctor Eduardo Castro Avalos
Details | Diff | Splinter Review
[PASSED QA] BUG 11602: [ENH] Fix localcover display (1.84 KB, patch)
2015-12-03 16:04 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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 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! :-)