[Koha-patches] [PATCH] [PATCH] [bug #2772][3.0.x] bad image location
Nahuel Angelinetti
nahuel.angelinetti at biblibre.com
Mon Nov 10 17:16:11 CET 2008
This patch make Page.pm to use the getitemtypeinfo function to generate the imageurl, and check (in the template) if an
image is set.
I backported a function from koha3.2, and the use of URI::Split.
Before this patch, always the "Alt" information was shown, because the url wasn't right.
Please enter the commit message for your changes.
---
C4/Koha.pm | 15 ++++++++++++++-
C4/VirtualShelves/Page.pm | 1 +
.../opac-tmpl/prog/en/modules/opac-shelves.tmpl | 5 ++++-
3 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/C4/Koha.pm b/C4/Koha.pm
index 846af3e..eb8b009 100644
--- a/C4/Koha.pm
+++ b/C4/Koha.pm
@@ -21,6 +21,7 @@ package C4::Koha;
use strict;
use C4::Context;
use C4::Output;
+use URI::Split qw(uri_split);
use vars qw($VERSION @ISA @EXPORT $DEBUG);
@@ -441,7 +442,7 @@ sub getitemtypeinfo {
$sth->execute($itemtype);
my $res = $sth->fetchrow_hashref;
- $res->{imageurl} = getitemtypeimagesrcfromurl( $res->{imageurl} );
+ $res->{imageurl} = getitemtypeimagelocation( 'intranet', $res->{imageurl} );
return $res;
}
@@ -494,6 +495,18 @@ sub getitemtypeimagesrc {
}
}
+sub getitemtypeimagelocation($$) {
+ my ( $src, $image ) = @_;
+
+ return '' if ( !$image );
+
+ my $scheme = ( uri_split( $image ) )[0];
+
+ return $image if ( $scheme );
+
+ return getitemtypeimagesrc( $src ) . '/' . $image;
+}
+
=head3 _getImagesFromDirectory
Find all of the image files in a directory in the filesystem
diff --git a/C4/VirtualShelves/Page.pm b/C4/VirtualShelves/Page.pm
index bcfd3af..f6a2f97 100755
--- a/C4/VirtualShelves/Page.pm
+++ b/C4/VirtualShelves/Page.pm
@@ -172,6 +172,7 @@ SWITCH: {
#$this_item->{imageurl} = $imgdir."/".$itemtypes->{ $this_item->{itemtype} }->{'imageurl'};
#$this_item->{'description'} = $itemtypes->{ $this_item->{itemtype} }->{'description'};
$this_item->{'dateadded'} = format_date($this_item->{'dateadded'});
+ $this_item->{'imageurl'} = getitemtypeinfo($this_item->{'itemtype'})->{'imageurl'};
}
$showadd = 1;
my $i = 0;
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tmpl
index 7e0db8e..e7bea8d 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tmpl
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tmpl
@@ -118,7 +118,10 @@ $.tablesorter.addParser({
</td>
<!-- /TMPL_IF -->
<!-- TMPL_UNLESS NAME="item-level_itypes" --><td>
- <img src="<!-- TMPL_VAR NAME="imageurl" -->" alt="<!-- TMPL_VAR NAME="description" -->" title="<!-- TMPL_VAR NAME="description" -->" /><!-- TMPL_VAR NAME="description" -->
+ <!-- TMPL_IF NAME="imageurl" -->
+ <img src="<!-- TMPL_VAR NAME="imageurl" -->" alt="<!-- TMPL_VAR NAME="description" -->" title="<!-- TMPL_VAR NAME="description" -->" />
+ </TMPL_IF>
+ <!-- TMPL_VAR NAME="description" -->
</td> <!-- /TMPL_UNLESS -->
<td><!-- TMPL_IF NAME="BiblioDefaultViewmarc" --><a class="title" href="/cgi-bin/koha/opac-MARCdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->"><!-- TMPL_VAR NAME="title" --> <!-- TMPL_VAR NAME="subtitle" --></a>
--
1.5.6.3
More information about the Koha-patches
mailing list