Skip to content

Commit

Permalink
Item10776:Item2485:Item2479:
Browse files Browse the repository at this point in the history
   * added new option 'thumbfile' to format string (Foswiki:Main/JoenioCosta)
   * speed improvement by not "ping-ing" each image on display
   * rendering thumbnails using newer method available in image::magick 6.5.x, the old method faild resizing and cropping on some platforms
   * removing =longdesc= from default image templates
   * now also caching urls to external images that include url params



git-svn-id: http://svn.foswiki.org/trunk/ImagePlugin@13571 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
MichaelDaum authored and MichaelDaum committed Jan 9, 2012
1 parent cb0a9d0 commit ab95367
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 116 deletions.
15 changes: 11 additions & 4 deletions data/System/ImagePlugin.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1266012866" format="1.1" version="1.2"}%
%META:TOPICINFO{author="ProjectContributor" date="1308213511" format="1.1" version="3"}%
<!--

PLEASE DO NOT EDIT THIS TOPIC
Expand Down Expand Up @@ -98,14 +98,14 @@ The image name is mandatory. Further arguments are optional.
| =title= | title text | *alt* value |
| =tooltipheight= | height of tooltip image | 300 |
| =tooltip= | on/off | off |
| =tooltipcrop= | on/northwest/north/northeast/west/center/east/southwest/south/southeast/off: same as =crop= but used for the tooltip |
| =tooltipcrop= | on/northwest/north/northeast/west/center/east/southwest/south/southeast/off: same as =crop= but used for the tooltip | |
| =tooltipwidth= | width of tooltip image | 300 |
| =topic= | valid topic name | topic part of IMGALBUM value or current topic |
| =type= | simple, plain, link, thumb[nail], frame, float | plain |
| =warn= | on/off, surpress error warnings | on |
| =web= | valid web name | web part of IMGALBUM value or current topic |
| =width= | integer value | image width |
| =zoom= | on/off to scale images, if set to "on" scaling up images is allowed, otherwise it downscales only | off
| =zoom= | on/off to scale images, if set to "on" scaling up images is allowed, otherwise it downscales only | off |

---+++ Tooltip preview
The =tooltip= argument allows rendering image previews in a tooltip. This option
Expand Down Expand Up @@ -151,6 +151,7 @@ pseudo variables:
| =$origwidth= | image width of the original image |
| =$percnt= | replaced with percent sign (%) |
| =$src= | image source url |
| =$thumbfile= | thumbnail image file name |
| =$style= | value of =style= argumet |
| =$text= | link text to be displayed in the "link" layout type |
| =$title= | value of =title= argument |
Expand Down Expand Up @@ -243,11 +244,17 @@ $Foswiki::cfg{ImagePlugin}{Mode} = 'Image::Magick';
* Set SHORTDESCRIPTION = Control the display and alignment of images using an easy syntax
-->
| Plugin Author: | Craig Meyer, Foswiki:Main.MichaelDaum |
| Copyright: | &copy; 2006, Craig Meyer, %BR% &copy; 2006-2010 Michael Daum http://michaeldaumconsulting.com |
| Copyright: | &copy; 2006, Craig Meyer, %BR% &copy; 2006-2012 Michael Daum http://michaeldaumconsulting.com |
| License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) |
| Release: | %$RELEASE% |
| Version: | %$VERSION% |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
| 09 Jan 2012: | added new option 'thumbfile' to format string (Foswiki:Main/JoenioCosta);\
speed improvement by not "ping-ing" each image on display; \
rendering thumbnails using newer method available in image::magick 6.5.x, the old method faild resizing and cropping on some platforms;\
removing =longdesc= from default image templates; \
now also caching urls to external images that include url params |
| 29 Jun 2011: | fixed detection of image links to the own wiki not to try an external download+mirror |
| 10 Jan 2011: | fixed parsing of mediawiki like params; \
fixed jquery interface to foswiki preferences; \
fixed dependency on !ZonePlugin to only be required for old foswiki versions; \
Expand Down
30 changes: 11 additions & 19 deletions lib/Foswiki/Plugins/ImagePlugin.pm
@@ -1,7 +1,7 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2006 Craig Meyer, meyercr@gmail.com
# Copyright (C) 2006-2010 Michael Daum http://michaeldaumconsulting.com
# Copyright (C) 2006-2012 Michael Daum http://michaeldaumconsulting.com
#
# Based on ImgPlugin
# Copyright (C) 2006 Meredith Lesly, msnomer@spamcop.net
Expand Down Expand Up @@ -32,7 +32,7 @@ use vars qw(
);

$VERSION = '$Rev$';
$RELEASE = '2.40';
$RELEASE = '2.41';
$NO_PREFS_IN_TOPIC = 1;

use Foswiki::Plugins ();
Expand All @@ -57,10 +57,15 @@ HERE
$doneRegisterJQueryPlugin = 0;

# register the tag handlers
Foswiki::Func::registerTagHandler( 'IMAGE', \&handleIMAGE);
Foswiki::Func::registerTagHandler( 'IMAGE', sub {
getCore($baseWeb, $baseTopic, shift)->handleIMAGE(@_);
});

# register rest handler
Foswiki::Func::registerRESTHandler('resize', \&handleREST);
Foswiki::Func::registerRESTHandler('resize', sub {
getCore($baseWeb, $baseTopic, shift)->handleREST(@_);
});


# SMELL: monkey-patching Foswiki::Render::_externalLink()
if ($Foswiki::cfg{ImagePlugin}{RenderExternalImageLinks}) {
Expand Down Expand Up @@ -96,20 +101,6 @@ HERE
return $imageCore;
}

###############################################################################
# schedule tag handlers
sub handleIMAGE {
my $session = shift;
getCore($baseWeb, $baseTopic, $session)->handleIMAGE(@_);
}

###############################################################################
sub handleREST {
my $session = shift;

getCore($baseWeb, $baseTopic, $session)->handleREST(@_);
}

###############################################################################
sub renderExternalLink {
my ($this, $url, $text) = @_;
Expand All @@ -128,7 +119,7 @@ sub renderExternalLink {
$text = '';
}

if ($url =~ /^(https?:).*\.(gif|jpg|jpeg|png)$/i && !$text) {
if ($url =~ /^(https?:).*\.(gif|jpg|jpeg|png)/i && !$text) {
my $pubUrl = $this->{session}->getPubUrl(1);
# skip "external links" to self and to any other excluded url
my $excludePattern = $Foswiki::cfg{ImagePlugin}{Exclude};
Expand All @@ -137,6 +128,7 @@ sub renderExternalLink {

# untaint url, check above
$url = Foswiki::Sandbox::untaintUnchecked($url);
$url =~ s/\?.*$//;

my $params = {
_DEFAULT => "$url",
Expand Down

0 comments on commit ab95367

Please sign in to comment.