Improve the performance of getThumbnailUrl by 1400%. Fixes bug #11346

This commit is contained in:
Colin Kuskie 2010-01-19 15:57:28 -08:00
parent ea53dcc037
commit 066e654640
3 changed files with 8 additions and 6 deletions

View file

@ -1247,14 +1247,15 @@ sub getThumbnailUrl {
my $self = shift;
my $filename = shift;
if (! defined $filename) {
$self->session->errorHandler->error("Can't make a thumbnail url without a filename.");
$self->session->errorHandler->error("Can't find a thumbnail url without a filename.");
return '';
}
if (! isIn($filename, @{ $self->getFiles() })) {
$self->session->errorHandler->error("Can't make a thumbnail for a file named '$filename' that is not in my storage location.");
my $thumbname = 'thumb-' . $filename;
if (! -e $self->getPath($thumbname)) {
$self->session->errorHandler->error("Can't find a thumbnail for a file named '$filename' that is not in my storage location.");
return '';
}
return $self->getUrl("thumb-".$filename);
return $self->getUrl($thumbname);
}
#-------------------------------------------------------------------