implement a thumbnail method for rendering article thumbs
authorTony Cook <tony@develop-help.com>
Sat, 2 Nov 2013 00:40:34 +0000 (11:40 +1100)
committerTony Cook <tony@develop-help.com>
Sat, 2 Nov 2013 00:40:34 +0000 (11:40 +1100)
site/cgi-bin/modules/Generate/Article.pm

index 71049f6..8121781 100644 (file)
@@ -16,7 +16,7 @@ use Carp 'confess';
 use BSE::Util::Iterate;
 use BSE::CfgInfo qw(cfg_dist_image_uri cfg_image_uri);
 
-our $VERSION = "1.012";
+our $VERSION = "1.013";
 
 =head1 NAME
 
@@ -718,6 +718,23 @@ HTML
   return %acts;
 }
 
+sub thumbnail {
+  my ($self, $which, $class) = @_;
+
+  if ($which->thumbImage) {
+    my $uri = $which->thumbImageUri;
+    my $width = $which->thumbWidth;
+    my $height = $which->thumbHeight;
+    my $html = qq(<img src="$uri" width="$width" height="$height");
+    $html .= qq( class="$class") if $class;
+    $html .= qq( border="0" alt="" />);
+    return $html;
+  }
+  else {
+    return "";
+  }
+}
+
 sub tag_ifStepAncestor {
   my ($article, $arg, $acts, $name, $templater) = @_;