Koha/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-showreviews-rss.tt
Jonathan Druart 1ea55acd0c Bug 26921: Don't generate an invalid custom cover image if the url cannot be generated
In case a custom cover image url is used to generate the cover image of
bibliographic records, we should not build one if the record does not
have the necessary data.

For instance if you have
CustomCoverImagesURL set to https://covers.openlibrary.org/b/isbn/{isbn}-M.jpb
and a biblio does not have the isbn defined, we should not generate and
empty image (empty or invalid src)

Test plan:
0.
Set CustomCoverImagesURL to https://covers.openlibrary.org/b/isbn/{isbn}-M.jpb
Enable CustomCoverImages and OPACCustomCoverImages
To highlight the issue you should disable LocalCoverImages and OPACLocalCoverImages.
1. Make sure you have some of your bibliographic records with a valid
isbn
2. Make sure you have at least 1 bibliographic record without an isbn
set
3. Visit the search result and detail views (OPAC and staff interfaces)
=> Without this patch you should see a "Cover image" link, and an empty
block/div on the detail page
=> With this patch applied you should only see images when the url can
be generated

Note that the problem will persist if the isbn is not valid (ie. no
image is generated)

Sponsored-by: Orex Digital
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2020-12-21 10:07:48 +01:00

48 lines
3.9 KiB
XML

[% USE KohaDates # XML declaration should have no white space before it %][% USE Koha %]<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title><![CDATA[[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] Catalog Recent Comments]]></title>
<link>[% OPACBaseURL | html %]/cgi-bin/koha/opac-showreviews.pl&amp;format=rss2</link>
<description><![CDATA[ The most recent comments from [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] Catalog. Comments can be made by logged in users and are moderated by library staff.]]></description>
<atom:link href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-showreviews.pl&amp;format=rss2" rel="self" type="application/rss+xml" />
<lastBuildDate>[% timestamp | html %]</lastBuildDate>
[% SET AdlibrisEnabled = Koha.Preference('AdlibrisCoversEnabled') %]
[% SET AdlibrisURL = Koha.Preference('AdlibrisCoversURL') %]
[% FOREACH review IN reviews %]
<item>
<title>New comment on [% INCLUDE 'biblio-title-head.inc' biblio=review %]</title>
<link>[% OPACBaseURL | html %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% review.biblionumber | html %]#comments</link>
<description><![CDATA[
[% IF ( AdlibrisEnabled && review.normalized_isbn ) %]
<img src="[% AdlibrisURL | html %]?isbn=[% review.normalized_isbn | html %]" alt="Adlibris cover image" />
[% END %]
[% IF ( OPACAmazonCoverImages ) %][% IF ( review.normalized_isbn ) %]<img src="https://images-na.ssl-images-amazon.com/images/P/[% review.normalized_isbn | html %].01.TZZZZZZZ.jpg" alt="" />[% END %][% END %]
[% IF ( SyndeticsEnabled ) %][% IF ( SyndeticsCoverImages ) %][% IF ( review.content_identifier_exists ) %]<img src="https://secure.syndetics.com/index.aspx?isbn=[% review.normalized_isbn | html %]/SC.GIF&amp;client=[% SyndeticsClientCode | html %]&amp;type=xw10&amp;upc=[% review.normalized_upc | html %]&amp;oclc=[% review.normalized_oclc | html %]" alt="" />
[% END %][% END %][% END %]
[% bt_id = ( review.normalized_upc || review.normalized_isbn ) %]
[% IF ( BakerTaylorEnabled && bt_id ) %]<a href="https://[% BakerTaylorBookstoreURL | uri %][% bt_id | uri %]"><img alt="See Baker &amp; Taylor" src="[% BakerTaylorImageURL | html %][% bt_id | html %]" /></a>[% END %]
[% IF Koha.Preference('OPACCustomCoverImages') AND Koha.Preference('CustomCoverImagesURL') %]
[% SET custom_cover_image_url = review.biblio_object.custom_cover_image_url %]
[% IF custom_cover_image_url %]
<a href="[% custom_cover_image_url | url %]"><img alt="Cover image" src="[% custom_cover_image_url | url %]" /></a>
[% END %]
[% END %]
[% IF ( review.author ) %]<p>By [% review.author | html %].</p> [% END %]
<p>[% IF ( review.place ) %][% review.place | html %] [% END %][% IF ( review.publishercode ) %][% review.publishercode | html %][% END %][% IF ( review.publicationyear ) %] [% review.publicationyear | html %]
[% ELSE %][% IF ( review.copyrightdate ) %] [% review.copyrightdate | html %][% END %][% END %]
[% IF ( review.pages ) %]. [% review.pages | html %][% END %]
[% IF ( review.notes ) %], [% review.notes | html %][% END %]
[% IF ( review.size ) %] [% review.size | html %]. [% END %]
[% IF ( review.isbn ) %] [% review.isbn | html %][% END %] </p>
<p>[% IF ( review.borrowernumber && ShowReviewer ) %][% review.firstname | html %] [% review.surname | html %] commented[% ELSE %]Comment[% END %] on [% review.datereviewed | $KohaDates %]: [% review.review | html %]</p>
]]></description>
<guid>[% OPACBaseURL | html %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% review.biblionumber | html %]&amp;reviewid=[% review.reviewid | html %]</guid>
<pubDate>[% review.timestamp | html %]</pubDate>
</item>
[% END %]
</channel>
</rss>