Changeset 12814
- Timestamp:
- 10/20/11 15:21:41 (19 months ago)
- File:
-
- 1 edited
-
trunk/core/lib/Foswiki/Render.pm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/core/lib/Foswiki/Render.pm
r12813 r12814 800 800 # [[$link][$text]] 801 801 $hasExplicitLinkLabel = 1; 802 if ( $text =~ /^[^?]*\.(gif|jpg|jpeg|png)$/i ) { 803 my $filename = $text; 804 $filename =~ s@.*/@@; 805 $text = CGI::img( { src => $text, alt => $filename } ); 802 if ( my $img = $this->_isImageLink($text) ) { 803 $text = $img; 806 804 } 807 805 else { … … 830 828 } 831 829 } 832 return _externalLink( $this,$link, $text );830 return $this->_externalLink( $link, $text ); 833 831 } 834 832 … … 891 889 } 892 890 891 # Check if text is an image # (as indicated by the file type) 892 # return an img tag, otherwise nothing 893 sub _isImageLink { 894 my ( $this, $url ) = @_; 895 896 if ( $url =~ /^[^?]*\.(?:gif|jpg|jpeg|png)$/i ) { 897 my $filename = $url; 898 $filename =~ s@.*/@@; 899 return CGI::img( { src => $url, alt => $filename } ); 900 } 901 return; 902 } 903 893 904 # Handle an external link typed directly into text. If it's an image 894 # (as indicated by the file type), and no text is specified, then use 895 # an img tag, otherwise generate a link. 905 # and no text is specified, then use an img tag, otherwise generate a link. 896 906 sub _externalLink { 897 907 my ( $this, $url, $text ) = @_; 898 908 899 if ( $url =~ /^[^?]*\.(gif|jpg|jpeg|png)$/i && !$text ) { 900 my $filename = $url; 901 $filename =~ s@.*/([^/]*)@$1@go; 902 return CGI::img( { src => $url, alt => $filename } ); 909 if ( !$text && ( my $img = $this->_isImageLink($url) ) ) { 910 return $img; 903 911 } 904 912 my $opt = '';
Note: See TracChangeset
for help on using the changeset viewer.
