EPrints Technical Mailing List Archive

Message: #01256


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

[EP-tech] Re: Thumbnails - documentation


One line in the email below isn't quite right:
$c->{plugins}->{'Convert::Thumbnails'}->{call_convert} = sub {
Should be:
$c->{plugins}->{'Convert::Thumbnails'}->{params}->{call_convert} = sub {

I've added the following page to the Wiki:
http://wiki.eprints.org/w/How_to_customise_thumbnails
If I've done anything stupid, or if you've done something fancy with your thumbnails, feel free to edit it!

Cheers,
John

-----Original Message-----
From: eprints-tech-bounces@ecs.soton.ac.uk [mailto:eprints-tech-bounces@ecs.soton.ac.uk] On Behalf Of John Salter
Sent: 29 October 2012 14:27
To: 'eprints-tech@ecs.soton.ac.uk'
Subject: [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
*** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
*** Archive: http://www.eprints.org/tech.php/
*** EPrints community wiki: http://wiki.eprints.org/