Skip to content

Commit

Permalink
Item552: import to foswiki svn from twiki.org
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/ThumbnailPlugin@1538 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
WillNorris authored and WillNorris committed Dec 23, 2008
0 parents commit b6099e1
Show file tree
Hide file tree
Showing 3 changed files with 629 additions and 0 deletions.
98 changes: 98 additions & 0 deletions data/TWiki/ThumbnailPlugin.txt
@@ -0,0 +1,98 @@
%META:TOPICINFO{author="X509_2fC_3dUS_2fST_3dMassachusetts_2fL_3dSouthborough_2fO_3dlitts_2enet_2fOU_3dLitt_20family_2fOU_3dNetwork_20Administration_2fCN_3dTimothe_20Litt_2femailAddress_3dtimothe_40litts_2enet" date="1229905855" format="1.1" reprev="1.2" version="1.2"}%
---+!! !ThumbnailPlugin

Thumbnails for everyone

%TOC%

---++ Syntax Rules

=%<nop>THUMBNAIL{ name="filename" variant="size" }%=

Given an image file name, returns the name of its thumbnail file of the given size.

Normally, you don't give the size, as it will default from a preference variable. But if you want an especially large (or small) icon selectively, the syntax allows for that.

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*

The thumbnail's size will be determined from the preference variable THUMBNAILPLUGIN_SIZE, which defaults to 150 (pixels).

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

Used with the !AttachLinkPlugin and !ImgPlugin, it becomes easy to do things like display hyperlinks to images as thumbnails of that image. Examples below.

This plugin requires the *[[http://search.cpan.org/search?query=GD&mode=all][GD]]* and *[[http://search.cpan.org/search?query=Image::MetaData::JPEG&mode=all][Image::MetaData::JPEG]]* libraries from CPAN.

---++ CAVEAT

This is a working prototype. Because of limitations of the current plugin interface, thumbnail auto-creation is unclean.
* Do not rely on the filenames or locations of the thumbnail files, which are subject to change.
* Do not name attachments <anything>_thumbnail_size.<anything> - these are the currently auto-created files.
* You probably will *not* want the {AutoAttachPubFiles} configuration option set, as the thumbnail files are not (yet) first class attachments.
* Until the plugin interface issues are resovled, this may break in future versions of the wiki.

It is intended, but not guaranteed that updates to correct these issues will not require changes to your topics. They may require running an upgrade script.

Although this warning may sound a bit scary, the plugin seems useful in its current state -- feedback is welcome (as is assistance with the plugin API issues, which are documented on twiki.org.)


---++ Examples

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

This is equivalent to the previously-required HTML markup

=&lt;a href="%<nop>ATTACHURL%/foo.jpg"&gt;&lt;img src="%<nop>ATTACHURL%/foo_thumbnail_150.jpg" align="left" /&gt;&lt;/a&gt;=

or the slightly better:

=%<nop>ATTACHMENT{ "foo.jpg" label="%<nop>IMG{ "foo_thumb_150.jpg" align="left" width="40" class="none" }%}%=

Of course, neither of the previous methods support multiple sizes as easily, nor are they as well abstracted from the attachment implementation.

---++ Plugin Settings

Plugin settings are stored as preferences variables. To reference a plugin setting write ==%<nop>&lt;plugin&gt;_&lt;setting&gt;%==, i.e. ==%<nop>NEWPLUGIN_SHORTDESCRIPTION%==

* One line description, is shown in the %TWIKIWEB%.TextFormattingRules topic:
* 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%.

---++ Plugin Installation Instructions

__Note:__ You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the TWiki server.

* Download the ZIP file from the Plugin Home (see below)
* Unzip *%TOPIC%.zip* in your twiki installation directory. Content:
| *File:* | *Description:* |
| ==data/TWiki/%TOPIC%.txt== | Plugin topic |
| ==data/TWiki/%TOPIC%.txt,v== | Plugin topic repository |
| ==lib/TWiki/Plugins/%TOPIC%.pm== | Plugin Perl module |
* Configure the Plugin:
* TWiki 4.0 and up: Run the [[%SCRIPTURL%/configure%SCRIPTSUFFIX%][configure]] script to enable the Plugin
* Change the Plugin settings as needed

---++ Plugin Info

| Plugin Author: | TWiki:Main.TimotheLitt |
| Copyright: | &copy; 2008, TWiki:Main.TimotheLitt |
| License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]], Perl artistic) |
| Plugin Version: | 21 Dec 2008 (V1.000) |
| Change History: | <!-- versions below in reverse order --> |
| 20 Dec 2008: | Initial version |
| TWiki Dependency: | $TWiki::Plugins::VERSION 1.1 |
| CPAN Dependencies: | GD:: Image::MetaData::JPEG |
| Other Dependencies: | none |
| Perl Version: | 5.005 |
| [[TWiki:Plugins/Benchmark][Benchmarks]]: | %TWIKIWEB%.GoodStyle nn%, %TWIKIWEB%.FormattedSearch nn%, %TOPIC% nn% |
| Plugin Home: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC% |
| Feedback: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Dev |
| Appraisal: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Appraisal |

__Related Topics:__ %TWIKIWEB%.TWikiPlugins, %TWIKIWEB%.DeveloperDocumentationCategory, %TWIKIWEB%.AdminDocumentationCategory, %TWIKIWEB%.TWikiPreferences http://TWiki.org/cgi-bin/view/Plugins/AttachmentPlugin http://TWiki.org/cgi-bin/view/Plugins/ImgPlugin

-- TWiki:Main.TimotheLitt - 21 Dec 2008
140 changes: 140 additions & 0 deletions data/TWiki/ThumbnailPlugin.txt,v
@@ -0,0 +1,140 @@
head 1.2;
access;
symbols;
locks; strict;
comment @# @;
expand @o@;


1.2
date 2008.12.22.00.30.55; author X509_2fC_3dUS_2fST_3dMassachusetts_2fL_3dSouthborough_2fO_3dlitts_2enet_2fOU_3dLitt_20family_2fOU_3dNetwork_20Administration_2fCN_3dTimothe_20Litt_2femailAddress_3dtimothe_40litts_2enet; state Exp;
branches;
next 1.1;

1.1
date 2008.12.21.21.58.46; author X509_2fC_3dUS_2fST_3dMassachusetts_2fL_3dSouthborough_2fO_3dlitts_2enet_2fOU_3dLitt_20family_2fOU_3dNetwork_20Administration_2fCN_3dTimothe_20Litt_2femailAddress_3dtimothe_40litts_2enet; state Exp;
branches;
next ;


desc
@none
@


1.2
log
@none
@
text
@%META:TOPICINFO{author="X509_2fC_3dUS_2fST_3dMassachusetts_2fL_3dSouthborough_2fO_3dlitts_2enet_2fOU_3dLitt_20family_2fOU_3dNetwork_20Administration_2fCN_3dTimothe_20Litt_2femailAddress_3dtimothe_40litts_2enet" date="1229905855" format="1.1" reprev="1.2" version="1.2"}%
---+!! !ThumbnailPlugin

Thumbnails for everyone

%TOC%

---++ Syntax Rules

=%<nop>THUMBNAIL{ name="filename" variant="size" }%=

Given an image file name, returns the name of its thumbnail file of the given size.

Normally, you don't give the size, as it will default from a preference variable. But if you want an especially large (or small) icon selectively, the syntax allows for that.

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*

The thumbnail's size will be determined from the preference variable THUMBNAILPLUGIN_SIZE, which defaults to 150 (pixels).

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

Used with the !AttachLinkPlugin and !ImgPlugin, it becomes easy to do things like display hyperlinks to images as thumbnails of that image. Examples below.

This plugin requires the *[[http://search.cpan.org/search?query=GD&mode=all][GD]]* and *[[http://search.cpan.org/search?query=Image::MetaData::JPEG&mode=all][Image::MetaData::JPEG]]* libraries from CPAN.

---++ CAVEAT

This is a working prototype. Because of limitations of the current plugin interface, thumbnail auto-creation is unclean.
* Do not rely on the filenames or locations of the thumbnail files, which are subject to change.
* Do not name attachments <anything>_thumbnail_size.<anything> - these are the currently auto-created files.
* You probably will *not* want the {AutoAttachPubFiles} configuration option set, as the thumbnail files are not (yet) first class attachments.
* Until the plugin interface issues are resovled, this may break in future versions of the wiki.

It is intended, but not guaranteed that updates to correct these issues will not require changes to your topics. They may require running an upgrade script.

Although this warning may sound a bit scary, the plugin seems useful in its current state -- feedback is welcome (as is assistance with the plugin API issues, which are documented on twiki.org.)


---++ Examples

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

This is equivalent to the previously-required HTML markup

=&lt;a href="%<nop>ATTACHURL%/foo.jpg"&gt;&lt;img src="%<nop>ATTACHURL%/foo_thumbnail_150.jpg" align="left" /&gt;&lt;/a&gt;=

or the slightly better:

=%<nop>ATTACHMENT{ "foo.jpg" label="%<nop>IMG{ "foo_thumb_150.jpg" align="left" width="40" class="none" }%}%=

Of course, neither of the previous methods support multiple sizes as easily, nor are they as well abstracted from the attachment implementation.

---++ Plugin Settings

Plugin settings are stored as preferences variables. To reference a plugin setting write ==%<nop>&lt;plugin&gt;_&lt;setting&gt;%==, i.e. ==%<nop>NEWPLUGIN_SHORTDESCRIPTION%==

* One line description, is shown in the %TWIKIWEB%.TextFormattingRules topic:
* 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%.

---++ Plugin Installation Instructions

__Note:__ You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the TWiki server.

* Download the ZIP file from the Plugin Home (see below)
* Unzip *%TOPIC%.zip* in your twiki installation directory. Content:
| *File:* | *Description:* |
| ==data/TWiki/%TOPIC%.txt== | Plugin topic |
| ==data/TWiki/%TOPIC%.txt,v== | Plugin topic repository |
| ==lib/TWiki/Plugins/%TOPIC%.pm== | Plugin Perl module |
* Configure the Plugin:
* TWiki 4.0 and up: Run the [[%SCRIPTURL%/configure%SCRIPTSUFFIX%][configure]] script to enable the Plugin
* Change the Plugin settings as needed

---++ Plugin Info

| Plugin Author: | TWiki:Main.TimotheLitt |
| Copyright: | &copy; 2008, TWiki:Main.TimotheLitt |
| License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]], Perl artistic) |
| Plugin Version: | 21 Dec 2008 (V1.000) |
| Change History: | <!-- versions below in reverse order --> |
| 20 Dec 2008: | Initial version |
| TWiki Dependency: | $TWiki::Plugins::VERSION 1.1 |
| CPAN Dependencies: | GD:: Image::MetaData::JPEG |
| Other Dependencies: | none |
| Perl Version: | 5.005 |
| [[TWiki:Plugins/Benchmark][Benchmarks]]: | %TWIKIWEB%.GoodStyle nn%, %TWIKIWEB%.FormattedSearch nn%, %TOPIC% nn% |
| Plugin Home: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC% |
| Feedback: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Dev |
| Appraisal: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Appraisal |

__Related Topics:__ %TWIKIWEB%.TWikiPlugins, %TWIKIWEB%.DeveloperDocumentationCategory, %TWIKIWEB%.AdminDocumentationCategory, %TWIKIWEB%.TWikiPreferences http://TWiki.org/cgi-bin/view/Plugins/AttachmentPlugin http://TWiki.org/cgi-bin/view/Plugins/ImgPlugin

-- TWiki:Main.TimotheLitt - 21 Dec 2008
@


1.1
log
@none
@
text
@d1 98
a98 2
%META:TOPICINFO{author="X509_2fC_3dUS_2fST_3dMassachusetts_2fL_3dSouthborough_2fO_3dlitts_2enet_2fOU_3dLitt_20family_2fOU_3dNetwork_20Administration_2fCN_3dTimothe_20Litt_2femailAddress_3dtimothe_40litts_2enet" date="1229896726" format="1.1" version="1.1"}%
-- Main.TimotheLitt - 21 Dec 2008
@

0 comments on commit b6099e1

Please sign in to comment.