18 September 2007

From Organic Design wiki
Revision as of 08:57, 18 September 2007 by Nad (talk | contribs) (News: Dynamic image resizing via URL)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Warning.svg This is a blog item that needs to be converted to the new Bliki format


Dynamic image resizing via URL

Wikimedia does URL-based image resizing on the fly as in the following example URL's. You can change the number of pixels to anything and it will return the image at that size.

This process uses the /wiki/thumb.php script which accepts two query-string parameters, f for the name of the image and w for the width of the re-sized image to be returned. Mod-rewrite can then be used to map requests to re-sized thumbnails to the script, eg:

RewriteCond %{REQUEST_URI} ^/files/thumb/./../.+?([0-9]+)px-(.+)$
RewriteRule ([0-9]+)px-(.+)$ /wiki/thumb.php?w=$1&f=$2 [L]