Skip to content

Commit

Permalink
Item552: ThumbnailPlugin fixed and tested
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/ThumbnailPlugin@1554 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
KennethLavrsen authored and KennethLavrsen committed Dec 23, 2008
1 parent a3b9095 commit d2c1eb7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
16 changes: 12 additions & 4 deletions data/System/ThumbnailPlugin.txt
Expand Up @@ -15,9 +15,11 @@ Normally, you don't give the size, as it will default from a preference variable

This plugin can be enabled on a per-topic, web, or site basis using the THUMBNAILPLUGIN_ENABLE preference variable.

When this plugin is enabled for a topic, any image attachment that is saved will have one or more thumbnails autogenerated for it. Image attachments types currently supported are: *.jpg .gif .png*
When this plugin is enabled, any image attachment that is saved will have one or more thumbnails autogenerated for it. Image attachments types currently supported are: *.jpg .gif .png*.

The thumbnail's size will be determined from the preference variable THUMBNAILPLUGIN_SIZE, which defaults to 150 (pixels).
You will probably not want this on any topic you attach images to so by default this plugin is normally disabled and you enable it either in each topic or at web level if you have a image gallery type web.

The thumbnail's size will be determined from the preference variable THUMBNAILPLUGIN_SIZE, which defaults to 150 (pixels). The thumbnails are generated when you upload an image as long as the plugin is enabled and no matter if there is a THUMBNAIL macro on the topic.

Use multiple sizes for accessibility as well as for esthetics. However, they do take time to generate, so don't go _too_ wild.

Expand All @@ -40,6 +42,12 @@ Although this warning may sound a bit scary, the plugin seems useful in its curr

---++ Examples

Basic example

%<nop>ATTACHURL%/%<nop>%THUMBNAIL{"foo.jpg" variant="50"}%

Example used with !AttachLinkPlugin and !ImgPlugin

=%<nop>ATTACHMENT{"foo.jpg" label="%<nop>IMG{"%<nop>THUMBNAIL{"foo.jpg"}%" align="left" }%"}%=

This is equivalent to the previously-required HTML markup
Expand All @@ -60,7 +68,7 @@ Plugin settings are stored as preferences variables. To reference a plugin setti
* Set SHORTDESCRIPTION = Painless links to attachments

* THUMBNAILPLUGIN_ENABLE = on, off : enables thumbnail auto-creation on save. Inherits by the usual preference rules.
* THUMBNAILPLUGIN_SIZE= decimal_number : defines the default size of auto-created thumbnails. You can specify a (space or comma-separated) list, in which case multiple thumbnails (1 of each size) will be generated. The first (or only) size listed is the default variant used by %<nop>THUMBNAIL%.
* THUMBNAILPLUGIN_SIZE = decimal_number : defines the default size of auto-created thumbnails. You can specify a (space or comma-separated) list, in which case multiple thumbnails (1 of each size) will be generated. The first (or only) size listed is the default variant used by %<nop>THUMBNAIL%. Default value is 150

---++ Plugin Installation Instructions

Expand All @@ -83,7 +91,7 @@ __Note:__ You do not need to install anything on the browser to use this plugin.
| License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]], Perl artistic) |
| Plugin Version: | 23 Dec 2008 (V1.001) |
| Change History: | <!-- versions below in reverse order --> |
| 23 Dec 2008: | V1.001 - Foswiki version by Kenneth Lavrsen |
| 23 Dec 2008: | V1.001 - Foswiki version by Kenneth Lavrsen. Bugs fixed so it actually gets enabled. Code tidied. Documentation improved. |
| 20 Dec 2008: | V1.000 - Initial version |
| Dependency: | $Foswiki::Plugins::VERSION 1.1 |
| CPAN Dependencies: | GD:: Image::MetaData::JPEG |
Expand Down
6 changes: 3 additions & 3 deletions lib/Foswiki/Plugins/ThumbnailPlugin.pm
Expand Up @@ -53,7 +53,7 @@ $RELEASE = 'ThumbnailPlugin 1.001';

$SHORTDESCRIPTION = 'Maintains thumbnails of attachements';

$NO_PREFS_IN_TOPIC = 1;
$NO_PREFS_IN_TOPIC = 0;

# Name of this Plugin, only used in this module
$pluginName = 'ThumbnailPlugin';
Expand Down Expand Up @@ -172,9 +172,9 @@ sub afterAttachmentSaveHandler {
my $type = $2;
return if( $error || $attName =~ m/_thumbnail\....$/ );

return unless( Foswiki::Func::getPreferencesFlag( "THUMBNAILPLUGIN_ENABLE", $web ) );
return unless( Foswiki::Func::getPreferencesFlag( "THUMBNAILPLUGIN_ENABLE" ) );

my $sizelist = Foswiki::Func::getPreferencesValue( "THUMBNAILPLUGIN_SIZE", $web ) || 150;
my $sizelist = Foswiki::Func::getPreferencesValue( "THUMBNAILPLUGIN_SIZE" ) || 150;

eval {
require GD;
Expand Down

0 comments on commit d2c1eb7

Please sign in to comment.