diff options
| author | Darkelarious <darkelarious@333networks.com> | 2017-09-25 23:13:47 +0200 |
|---|---|---|
| committer | Darkelarious <darkelarious@333networks.com> | 2017-09-25 23:13:47 +0200 |
| commit | 18921404e5454cdf202b7b4f70a2777f3e297998 (patch) | |
| tree | d24abef8f510998423cb8f107228e253ee6b4825 /lib/MasterWebInterface/Util/Figures.pm | |
| download | WebInterface-Perl-MS-Perl-18921404e5454cdf202b7b4f70a2777f3e297998.tar.gz WebInterface-Perl-MS-Perl-18921404e5454cdf202b7b4f70a2777f3e297998.zip | |
Web interface for MasterServer-Perl
Diffstat (limited to 'lib/MasterWebInterface/Util/Figures.pm')
| -rwxr-xr-x | lib/MasterWebInterface/Util/Figures.pm | 38 |
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; |
