| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
15
|
|
|
15
|
|
6472
|
use strict; |
|
|
15
|
|
|
|
|
19
|
|
|
|
15
|
|
|
|
|
468
|
|
|
2
|
15
|
|
|
15
|
|
63
|
use warnings; |
|
|
15
|
|
|
|
|
18
|
|
|
|
15
|
|
|
|
|
750
|
|
|
3
|
|
|
|
|
|
|
package HTML::Widget::Plugin::Image; |
|
4
|
|
|
|
|
|
|
# ABSTRACT: an image object |
|
5
|
|
|
|
|
|
|
$HTML::Widget::Plugin::Image::VERSION = '0.203'; |
|
6
|
15
|
|
|
15
|
|
62
|
use parent 'HTML::Widget::Plugin'; |
|
|
15
|
|
|
|
|
16
|
|
|
|
15
|
|
|
|
|
65
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
|
9
|
|
|
|
|
|
|
#pod |
|
10
|
|
|
|
|
|
|
#pod $widget_factory->image({ |
|
11
|
|
|
|
|
|
|
#pod src => 'http://example.com/example.jpg', |
|
12
|
|
|
|
|
|
|
#pod alt => 'An Example Image', |
|
13
|
|
|
|
|
|
|
#pod }); |
|
14
|
|
|
|
|
|
|
#pod |
|
15
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
|
16
|
|
|
|
|
|
|
#pod |
|
17
|
|
|
|
|
|
|
#pod This plugin provides a basic image widget. |
|
18
|
|
|
|
|
|
|
#pod |
|
19
|
|
|
|
|
|
|
#pod =cut |
|
20
|
|
|
|
|
|
|
|
|
21
|
15
|
|
|
15
|
|
784
|
use Carp (); |
|
|
15
|
|
|
|
|
21
|
|
|
|
15
|
|
|
|
|
255
|
|
|
22
|
15
|
|
|
15
|
|
59
|
use HTML::Element; |
|
|
15
|
|
|
|
|
18
|
|
|
|
15
|
|
|
|
|
74
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
#pod =head1 METHODS |
|
25
|
|
|
|
|
|
|
#pod |
|
26
|
|
|
|
|
|
|
#pod =head2 C< provided_widgets > |
|
27
|
|
|
|
|
|
|
#pod |
|
28
|
|
|
|
|
|
|
#pod This plugin provides the following widgets: image |
|
29
|
|
|
|
|
|
|
#pod |
|
30
|
|
|
|
|
|
|
#pod =cut |
|
31
|
|
|
|
|
|
|
|
|
32
|
16
|
|
|
16
|
1
|
34
|
sub provided_widgets { qw(image) } |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
#pod =head2 C< image > |
|
35
|
|
|
|
|
|
|
#pod |
|
36
|
|
|
|
|
|
|
#pod This method returns a basic image element. |
|
37
|
|
|
|
|
|
|
#pod |
|
38
|
|
|
|
|
|
|
#pod In addition to the generic L attributes, the following |
|
39
|
|
|
|
|
|
|
#pod are valid arguments: |
|
40
|
|
|
|
|
|
|
#pod |
|
41
|
|
|
|
|
|
|
#pod =over |
|
42
|
|
|
|
|
|
|
#pod |
|
43
|
|
|
|
|
|
|
#pod =item src |
|
44
|
|
|
|
|
|
|
#pod |
|
45
|
|
|
|
|
|
|
#pod This is the source href for the image. "href" is a synonym for src. If no |
|
46
|
|
|
|
|
|
|
#pod href is supplied, an exception is thrown. |
|
47
|
|
|
|
|
|
|
#pod |
|
48
|
|
|
|
|
|
|
#pod =item alt |
|
49
|
|
|
|
|
|
|
#pod |
|
50
|
|
|
|
|
|
|
#pod This is the alt text for the image. |
|
51
|
|
|
|
|
|
|
#pod |
|
52
|
|
|
|
|
|
|
#pod =back |
|
53
|
|
|
|
|
|
|
#pod |
|
54
|
|
|
|
|
|
|
#pod =cut |
|
55
|
|
|
|
|
|
|
|
|
56
|
16
|
|
|
16
|
|
48
|
sub _attribute_args { qw(src alt) } |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub image { |
|
59
|
4
|
|
|
4
|
1
|
7
|
my ($self, $factory, $arg) = @_; |
|
60
|
|
|
|
|
|
|
|
|
61
|
4
|
100
|
100
|
|
|
21
|
if ($arg->{attr}{src} and $arg->{href}) { |
|
62
|
1
|
|
|
|
|
220
|
Carp::croak "don't provide both href and src for image widget"; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
3
|
100
|
|
|
|
41
|
$arg->{attr}{src} = $arg->{href} if not defined $arg->{attr}{src}; |
|
66
|
|
|
|
|
|
|
|
|
67
|
3
|
100
|
|
|
|
152
|
Carp::croak "can't create an image without a src" |
|
68
|
|
|
|
|
|
|
unless defined $arg->{attr}{src}; |
|
69
|
|
|
|
|
|
|
|
|
70
|
2
|
|
|
|
|
11
|
my $widget = HTML::Element->new('img'); |
|
71
|
2
|
|
|
|
|
62
|
$widget->attr($_ => $arg->{attr}{$_}) for keys %{ $arg->{attr} }; |
|
|
2
|
|
|
|
|
16
|
|
|
72
|
|
|
|
|
|
|
|
|
73
|
2
|
|
|
|
|
64
|
return $widget->as_XML; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__END__ |