Last modified: 2006-08-18 17:32:09 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T9044, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 7044 - "Add leading zeros" magic word
"Add leading zeros" magic word
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Parser (Other open bugs)
unspecified
All All
: Normal enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2006-08-17 15:40 UTC by emddudley
Modified: 2006-08-18 17:32 UTC (History)
0 users

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description emddudley 2006-08-17 15:40:44 UTC
I'd like to request a "magic word" similar to {{formatnum:}} that pads a number
with leading zeros.

Many images on Commons are uploaded as a series with leading zeros on the
image's index. For example, all of the images at
http://commons.wikimedia.org/wiki/User:BradPatrick/gallery have leading zeros.
Many cameras default to using leading zeros in their filenames. Automatically
generating these filenames in a template is difficult.

I don't want to encourage leading zeros in filenames, but if someone wants to
upload a large number of images, it's a huge pain to rename them all.

Examples:
* {{padzeros:2|4}} would render as 0002
* {{padzeros:02|4}} as 0002
* {{padzeros:0002|2}} as 02
* {{padzeros:1024|-1}} as 1024
* {{padzeros:1024|2}} as 1024
Comment 1 Rob Church 2006-08-18 17:32:09 UTC
Added two new colon functions in SVN trunk, r16126; "padleft" and "padright":

{{padleft:STRING|LENGTH|CHARACTER}}

where STRING is the start string, LENGTH is the desired end length, and
CHARACTER is an (optional) character used for padding. The format for "padright"
is identical save for the function name.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links