Changeset 5548
- Timestamp:
- 11/17/09 14:43:03 (3 years ago)
- Location:
- trunk/ImagePlugin
- Files:
-
- 5 edited
-
data/System/ImagePlugin.txt (modified) (5 diffs)
-
lib/Foswiki/Plugins/ImagePlugin.pm (modified) (1 diff)
-
lib/Foswiki/Plugins/ImagePlugin/Core.pm (modified) (7 diffs)
-
pub/System/ImagePlugin/jquery.tooltippreview.js.gz (modified) (previous)
-
pub/System/ImagePlugin/style.css.gz (modified) (previous)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ImagePlugin/data/System/ImagePlugin.txt
r5127 r5548 93 93 | =refresh= | on/off/img to trigger recomputing images | off | 94 94 | =size= | geometry specification | image geometry | 95 | =zoom= | on/off | if set to "on" scaling up images is allowed, otherwise it downscales only | off | 95 96 | =style= | (see html specs) | empty | 96 97 | =title= | title text | *alt* value | … … 118 119 measure use the =width= and =height= arguments. 119 120 121 Note, that you must set =zoom="on"= to scale images up. Otherwise images smaller 122 than the given gemoentry will stay as hey are. For instance, when generating thumbnails 123 it is preferable to keep small icons as they are instead of bloating them up 124 to a standard thumbnail size. 120 125 121 126 ---+++ Format specification … … 176 181 | =height= | height of thumbnail | | 177 182 | =size= | geometry of thumbnail | | 183 | =zoom= | switch on/off upscaling | | 178 184 | =refresh= | on/off/img to trigger recomputing images | off | 179 185 … … 239 245 | Version: | %$VERSION% | 240 246 | Change History: | <!-- versions below in reverse order --> | 247 | 17 Nov 2009: | added =zoom= parameter; fixed manual refresh via url params | 241 248 | 24 Sep 2009: | updated =imageplugin.template= to help XHTML validation (stop rendering empty id attribute) | 242 249 | 14 Sep 2009: | using Foswiki's proxy settings instead of ENV; disabled tooltip previews for Internet Explorers | … … 277 284 278 285 279 %META:FILEATTACHMENT{name="WestminstpalaceSample.png" attr="h" autoattached="1"comment="" date="1185796830" path="WestminstpalaceSample.png" size="107728" user="ProjectContributor" version="1"}%286 %META:FILEATTACHMENT{name="WestminstpalaceSample.png" attr="h" comment="" date="1185796830" path="WestminstpalaceSample.png" size="107728" user="ProjectContributor" version="1"}% -
trunk/ImagePlugin/lib/Foswiki/Plugins/ImagePlugin.pm
r4910 r5548 32 32 33 33 $VERSION = '$Rev$'; 34 $RELEASE = '2. 12';34 $RELEASE = '2.20'; 35 35 36 use Foswiki::Plugins ;37 use Foswiki::Render ;36 use Foswiki::Plugins (); 37 use Foswiki::Render (); 38 38 39 39 ############################################################################### -
trunk/ImagePlugin/lib/Foswiki/Plugins/ImagePlugin/Core.pm
r4910 r5548 102 102 my $height = $query->param('height') || ''; 103 103 my $size = $query->param('size') || ''; 104 my $zoom = $query->param('zoom') || 'off'; 104 105 my $refresh = $query->param('refresh') || ''; 105 106 $refresh = ($refresh =~ /^(on|1|yes|img)$/g)?1:0; … … 107 108 #writeDebug("processing image"); 108 109 my $imgInfo = $this->processImage($imgWeb, $imgTopic, $imgFile, 109 $size, $ width, $height, $refresh);110 $size, $zoom, $width, $height, $refresh); 110 111 unless ($imgInfo) { 111 112 Foswiki::Func::writeWarning("ImagePlugin - $this->{errorMsg}"); … … 153 154 $params->{mouseout} ||= ''; 154 155 $params->{style} ||= ''; 156 $params->{zoom} ||= 'off'; 155 157 $params->{tooltip} ||= 'off'; 156 158 $params->{tooltipwidth} ||= '300'; … … 305 307 my $imgInfo = 306 308 $this->processImage($imgWeb, $imgTopic, $origFile, 307 $params->{size}, $params->{ width}, $params->{height}, $doRefresh);309 $params->{size}, $params->{zoom}, $params->{width}, $params->{height}, $doRefresh); 308 310 309 311 unless ($imgInfo) { … … 442 444 # returns undef on error 443 445 sub processImage { 444 my ($this, $imgWeb, $imgTopic, $imgFile, $size, $ width, $height, $doRefresh) = @_;445 446 writeDebug("called processImage($imgWeb, $imgTopic, $imgFile, $size, $ width, $height, $doRefresh)");446 my ($this, $imgWeb, $imgTopic, $imgFile, $size, $zoom, $width, $height, $doRefresh) = @_; 447 448 writeDebug("called processImage($imgWeb, $imgTopic, $imgFile, $size, $zoom, $width, $height, $doRefresh)"); 447 449 448 450 $this->{errorMsg} = ''; … … 460 462 $imgInfo{origHeight} ||= 0; 461 463 464 if ($size) { 465 if ($zoom ne 'on' && ($size > $imgInfo{origHeight} || $size > $imgInfo{origWidth})) { 466 writeDebug("not zooming to size $size"); 467 $size = ''; 468 } 469 } 470 462 471 if ($size || $width || $height || $doRefresh) { 463 472 # read orig width and height 464 473 if ($width || $height) { 474 465 475 # keep aspect ratio 466 476 my $aspect = $imgInfo{origWidth} ? $imgInfo{origHeight} / $imgInfo{origWidth} : 0; 467 477 my $newHeight = $imgInfo{origHeight}; 468 478 my $newWidth = $imgInfo{origWidth}; 469 if ($width && $newWidth > $width) { 479 480 if ($width && $imgInfo{origWidth} > $width) { # scale down width 470 481 $newHeight = $width * $aspect; 471 482 $newWidth = $width; 472 483 } 473 if ($height && $newHeight > $height) { 484 485 if ($height && $newHeight > $height) { # scale down height 474 486 $newWidth = $aspect ? $height / $aspect : 0; 475 487 $newHeight = $height; 476 488 } 489 490 if ($zoom ne 'on' && ($newHeight > $imgInfo{origHeight} || $newWidth > $imgInfo{origWidth})) { 491 writeDebug("not zooming"); 492 $newHeight = $imgInfo{origHeight}; 493 $newWidth = $imgInfo{origWidth}; 494 } 495 477 496 $width = int($newWidth+0.5); 478 497 $height = int($newHeight+0.5); 479 #writeDebug("origWidth=$imgInfo{origWidth} origHeight=$imgInfo{origHeight} aspect=$aspect width=$width height=$height");480 } 481 498 writeDebug("origWidth=$imgInfo{origWidth} origHeight=$imgInfo{origHeight} aspect=$aspect width=$width height=$height"); 499 } 500 482 501 my $newImgFile = $this->getImageFile($width, $height, $size, $imgFile); 483 502 my $newImgPath = $imgPath.'/'.$newImgFile; … … 680 699 my $topicInfo = $meta->get('TOPICINFO'); 681 700 $attachment->{name} = $baseFilename; 682 $attachment->{attachment} = $ filename;701 $attachment->{attachment} = $baseFilename; # BTW: not documented in System.MetaData 683 702 $attachment->{date} = time(); 684 703 $attachment->{version} ||= 1;
Note: See TracChangeset
for help on using the changeset viewer.
