aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Reaction/UI/Widget/Image.pm
blob: 705859d1ec1f9bce614dfc16919da4b95e3b42da (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package Reaction::UI::Widget::Image;

use Reaction::UI::WidgetClass;
use namespace::clean -except => [ qw(meta) ];

before fragment widget {
  my $vp = $_{viewport};
  my $attrs = {
    src => $vp->uri,
    ($vp->has_width ? (width => $vp->width) : ()),
    ($vp->has_height ? (height => $vp->height) : ()),
  };
  arg img_attrs => attrs( $attrs );
};

__PACKAGE__->meta->make_immutable;

1;

__END__;

=head1 NAME

Reaction::UI::Widget::Image - An image with optional height and width properties

=head1 DESCRIPTION

=head1 FRAGMENTS

=head2 widget

The widget layout will be provided with an additional C<img_attrs> argument containing
a rendered string of the image's attributes containing:

=over 4

=item src

The return value of the viewports C<uri> method.

=item width

The value of the viewports C<width> attribute if one was found.

=item height

The value of the viewports C<height> attribute if one was found.

=back

=head1 LAYOUT SETS

  share/skin/base/layout/image.tt

=head1 AUTHORS

See L<Reaction::Class> for authors.

=head1 LICENSE

See L<Reaction::Class> for the license.

=cut