aboutsummaryrefslogtreecommitdiff
path: root/lib/MasterWebInterface/Util/Figures.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/MasterWebInterface/Util/Figures.pm')
-rwxr-xr-xlib/MasterWebInterface/Util/Figures.pm38
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/MasterWebInterface/Util/Figures.pm b/lib/MasterWebInterface/Util/Figures.pm
new file mode 100755
index 0000000..a3f3e5f
--- /dev/null
+++ b/lib/MasterWebInterface/Util/Figures.pm
@@ -0,0 +1,38 @@
+package MasterWebInterface::Util::Figures;
+use strict;
+use warnings;
+use TUWF ':html';
+use Exporter 'import';
+use Image::Size;
+our @EXPORT = qw| figure figurelink |;
+
+################################################################################
+# Load image in Yorhel's IV.
+################################################################################
+sub figure {
+ my ($self, $d, $f, $s) = @_;
+ my $extra_css = (defined($s)) ? "style=\"$s\"" : "";
+ my ($w, $h) = imgsize("$self->{img_path}/$d/$f");
+ # make a link and show a thumbnail if exists, else photo itself
+ if (-e "$self->{img_path}/t/$f") {
+ lit "<a rel=\"iv:$w"."x"."$h\" href=\"/img/$d/$f\"><img $extra_css src=\"/img/t/$f\" alt=\"$f\"/></a> "
+ }
+ else{
+ lit "<a rel=\"iv:$w"."x"."$h\" href=\"/img/$d/$f\"><img $extra_css src=\"/img/$d/$f\" alt=\"$f\"/></a> "}
+}
+
+################################################################################
+# Have a picture $f link to destination $dest -- wrapper function
+################################################################################
+sub figurelink {
+ my ($self, $d, $f, $dest) = @_;
+ # make a link and show a thumbnail if exists, else photo itself
+ if (-e "$self->{img_path}/t/$f") {
+ lit "<a href=\"$dest\"><img src=\"/img/t/$f\" alt=\"$f\"/></a> "
+ }
+ else{
+ lit "<a href=\"$dest\"><img src=\"/img/$d/$f\" alt=\"$f\"/></a> "}
+}
+
+
+1;