@@ -, +, @@ --- Koha/Biblio.pm | 5 +++++ .../prog/en/modules/admin/preferences/enhanced_content.pref | 2 +- t/db_dependent/Koha/Biblios.t | 8 ++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) --- a/Koha/Biblio.pm +++ a/Koha/Biblio.pm @@ -22,6 +22,7 @@ use Modern::Perl; use Carp; use List::MoreUtils qw(any); +use C4::Koha; use C4::Biblio qw(); use Koha::Database; @@ -483,6 +484,10 @@ sub custom_cover_image_url { my $isbn = $self->biblioitem->isbn; $url =~ s|%isbn%|$isbn|g; } + if ( $url =~ m|%normalized_isbn%| ) { + my $normalized_isbn = C4::Koha::GetNormalizedISBN($self->biblioitem->isbn); + $url =~ s|%normalized_isbn%|$normalized_isbn|g; + } if ( $url =~ m|%issn%| ) { my $issn = $self->biblioitem->issn; $url =~ s|%issn%|$issn|g; --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref @@ -346,7 +346,7 @@ Enhanced Content: - "Using the following URL:" - pref: CustomCoverImagesURL class: url - - "You can defined it using the following patterns: %isbn%, %issn%." + - "You can define it using the following patterns: %isbn%, %issn%, %normalized_isbn%." HTML5 Media: - - Show a tab with a HTML5 media player for files catalogued in field 856 --- a/t/db_dependent/Koha/Biblios.t +++ a/t/db_dependent/Koha/Biblios.t @@ -188,11 +188,11 @@ subtest 'can_be_transferred' => sub { }; subtest 'custom_cover_image_url' => sub { - plan tests => 2; + plan tests => 3; t::lib::Mocks::mock_preference( 'CustomCoverImagesURL', 'https://my_url/%isbn%_%issn%.png' ); - my $isbn = 'my_isbn'; + my $isbn = '0553573403 | 9780553573404 (pbk.).png'; my $issn = 'my_issn'; my $marc_record = MARC::Record->new; my ( $biblionumber, undef ) = C4::Biblio::AddBiblio($marc_record, ''); @@ -208,6 +208,10 @@ subtest 'custom_cover_image_url' => sub { t::lib::Mocks::mock_preference( 'CustomCoverImagesURL', 'https://my_url/%024$a%.png' ); is( $biblio->custom_cover_image_url, "https://my_url/$marc_024a.png" ); + + t::lib::Mocks::mock_preference( 'CustomCoverImagesURL', 'https://my_url/%normalized_isbn%.png' ); + my $normalized_isbn = C4::Koha::GetNormalizedISBN($isbn); + is( $biblio->custom_cover_image_url, "https://my_url/$normalized_isbn.png" ); }; $schema->storage->txn_rollback; --