| 1 | # $Id: xIMG.pm 284 2006-12-01 07:51:49Z chronos $ | ||
| 2 | package BBCode::Tag::xIMG; | ||
| 3 | use base qw(BBCode::Tag::Inline); | ||
| 4 | use BBCode::Util qw(:parse :encode :text); | ||
| 5 | use strict; | ||
| 6 | use warnings; | ||
| 7 | our $VERSION = '0.34'; | ||
| 8 | |||
| 9 | sub Tag($):method { | ||
| 10 | return 'IMG'; | ||
| 11 | } | ||
| 12 | |||
| 13 | sub BodyPermitted($):method { | ||
| 14 | return 1; | ||
| 15 | } | ||
| 16 | |||
| 17 | sub replace($):method { | ||
| 18 | my $this = shift; | ||
| 19 | my $text = $this->bodyHTML; | ||
| 20 | my $url = parseURL decodeHTML $text; | ||
| 21 | |||
| 22 | if(defined $url) { | ||
| 23 | return BBCode::Tag->new( | ||
| 24 | $this->parser, | ||
| 25 | 'IMG', | ||
| 26 | [ undef, $url->as_string ], | ||
| 27 | [ 'ALT', textALT($url) ], | ||
| 28 | ); | ||
| 29 | } else { | ||
| 30 | return BBCode::Tag->new($this->parser, 'TEXT', [ undef, $text ]); | ||
| 31 | } | ||
| 32 | } | ||
| 33 | |||
| 34 | 1; |