EPrints Technical Mailing List Archive

Message: #01253


< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

[EP-tech] Thumbnails - documentation


Hi,
I'm adding a new thumbnail size to my archive.
The documentation here: http://wiki.eprints.org/w/API:EPrints/Plugin/Convert/Thumbnails doesn't really explain fully what you need to do. I've got it working, but wondered if I'd done it the *right* way.
Anyone care to comment?
If what I've done is *right*, I'll add it to the wiki!

This is what I did:
1. In ~/archives/[ARCHIVEID]/cfg/cfg.d/plugins.pl, add:
$c->{plugins}->{'Convert::Thumbnails'}->{params}->{sizes} = {(
        small => [66,50],
        homepage => [160, 90], #This is the new one
        medium => [200,150],
        preview => [400,300],
        lightbox => [640,480],
)};
$c->{thumbnail_types} = sub {
        my( $list, $repo, $doc ) = @_;
        push @$list, qw( homepage );
};

So far so good - this gets the new thumbnail size to be generated, but it's a scaled down version of the original, not a cropped version (e.g. like a 'medium' thumbnail, not like 'small' thumbnail).

The code that decides how to process the thumbnails (sub call_convert) is copied from ~/perl_lib/EPrints/Plugin/Convert/Thumbnails.pm, and added to ~/archives/[ARCHIVEID]/cfg/cfg.d/plugins.pl:
$c->{plugins}->{'Convert::Thumbnails'}->{call_convert} = sub {
	my( $self, $dir, $doc, $src, $geom, $size ) = @_;
	...
	#change _system call for 'homepage' size
	...
};

Is all/any of that sane/insane?
Cheers,
John