Permalink
Browse files
allow thumbnail width to be defined in node
- Loading branch information...
Showing
with
6 additions
and
3 deletions.
-
+2
−2
lib/Blio/Image.pm
-
+3
−1
lib/Blio/Node.pm
-
+1
−0
t/testdata/site_images/iceland/geysir.txt
|
@@ -35,14 +35,14 @@ sub publish { |
|
|
}
|
|
|
|
|
|
sub make_thumbnail {
|
|
|
- my ($self, $blio) = @_;
|
|
|
+ my ($self, $blio, $width) = @_;
|
|
|
|
|
|
$blio->output_dir->file($self->url)->parent->mkpath;
|
|
|
my $file = $self->source_file->stringify;
|
|
|
my $target = $blio->output_dir->file($self->thumbnail)->stringify;
|
|
|
my $image = Imager->new;
|
|
|
$image->read(file=>$file) || die "Cannot read image $file: ".$image->errstr;
|
|
|
- my $width = $blio->thumbnail;
|
|
|
+ $width ||= $blio->thumbnail;
|
|
|
my $thumbnail = $image->scale(xpixels => $width) || die "Cannot scale $file: ".$image->errstr;
|
|
|
$thumbnail->write( file => $target ) || die "Cannot write thumbnail $target" . $thumbnail->errstr;
|
|
|
}
|
|
|
|
@@ -104,6 +104,8 @@ has 'images' => ( |
|
|
},
|
|
|
);
|
|
|
has 'inline_images' => (is=>'ro',isa=>'Bool',default=>0);
|
|
|
+has 'thumbnail' => (is=>'ro',isa=>'Int');
|
|
|
+
|
|
|
has 'children' => (
|
|
|
is => 'rw',
|
|
|
isa => 'ArrayRef[Blio::Node]',
|
|
@@ -218,7 +220,7 @@ sub write { |
|
|
if ($blio->force || !-e $blio->output_dir->file($img->thumbnail)) {
|
|
|
say "\timage ".$img->url unless $blio->quiet;
|
|
|
$img->publish($blio);
|
|
|
- $img->make_thumbnail($blio);
|
|
|
+ $img->make_thumbnail($blio, $self->thumbnail);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1,6 +1,7 @@ |
|
|
title: Geysir
|
|
|
inline_images: 1
|
|
|
converter: textile
|
|
|
+thumbnail: 400
|
|
|
|
|
|
more water
|
|
|
|
|
|
0 comments on commit
b9e1528