Mediawiki file size/example

From Bjoern Hassler

Jump to: navigation, search

Example with Image:Mediawiki sunflower.png

Contents

[edit] 1 Basic file size

{{#filesize:Image:Mediawiki sunflower.png}}

gives the filesize of that image, which is 503 kB

{{#filesize:Media:Mediawiki sunflower.pdf}}

gives the filesize of that document, which is 38 kB. The same with 'Image' instead of 'Media' also works: 38 kB. Omitting 'Media' also works: 38 kB.

[edit] 2 Get file size for thumbnail

{{#filesize:Image:Mediawiki sunflower.png|50}}

constrains the image to width 50px. The size is 7 kB for this thumbnail: Image:Mediawiki sunflower.png (50x50, 7 kB)

{{#filesize:Image:Mediawiki sunflower.png|50x30}}

constrains the size to within 50x30. Size is 3 kB for this image: Image:Mediawiki sunflower.png (30x30, 3 kB)

{{#filesize:Image:Mediawiki sunflower.png|10x30}}

constrains the size to within 10x30. Size is 1 kB for this image: Image:Mediawiki sunflower.png (10x10, 1 kB)

{{#filesize:Image:Mediawiki sunflower.png|x30}}

constrains the height to within 30. Size is 3 kB for this image: Image:Mediawiki sunflower.png (30x30, 3 kB)

[edit] 3 Specify a size, and help

{{#filesize:Image:Mediawiki sunflower.png|50x30|help}}

Diagnostics from FILESIZE:
param1=Image:Mediawiki sunflower.png
url=/wiki_source/images/thumb/7/70/Mediawiki_sunflower.png/30px-Mediawiki_sunflower.png,
fullurl=http://www.sciencemedianetwork.com/wiki_source/images/thumb/7/70/Mediawiki_sunflower.png/30px-Mediawiki_sunflower.png
filesize=3244 B, 3 kB (rounded)
Was it resized? 1
requested contraint=50x30 (50,30)
(width,height)=(30,30)
[ [Image:Mediawiki sunflower.png|30px] ]=Mediawiki sunflower.png3 kB

[edit] 4 Specify a size, and provide a preview

{{#filesize:Image:Mediawiki sunflower.png|50x40|preview}}

You can use the preview option to generate some information and a preview, to help choose a good image size and file size. The above command produces:

Image:Mediawiki sunflower.png, 50x40 -> Image:Mediawiki sunflower.png|40px -> Mediawiki sunflower.png, 40x40, 5 kB

Note how the requested size was 50x40, and the function returns the appropriate wiki code to produce the required dimensions.

[edit] 5 Linking and showing the filesize

For generic documents, Media:...pdf and Image:...pdf link to the media, and to the media page respectively:

For images this is the same, Media:...jpg links to the (full res)image, while Image:...jpg links to the Image page.

If you specify a thumb size, we need to link out to the thumb. (Media and Image have same effect.) You can do it like this:

If you specify linkfull and and thumb size, this has the same effect as specifying linkthumb in the first place. (Giving the size of the thumb and linking to the full image makes no sense.) Example:

[edit] 6 Other experiments

  • 50px|thumb|(50x50, 7 kB) Parameters: {{#filesize:Media:Mediawiki sunflower.png|50x100|showthumb showparams}}
  • (50x50, 7 kB)
    Parameters: {{#filesize:Image:Mediawiki sunflower.png|50x100|showthumb showparams}}

Output useful for api calls in mirroring script (needs further work to give proper serialised output):

[edit] 7 gallery

Mediawiki file size/gallery

[edit] 8 related functions

fullurl: http://www.sciencemedianetwork.com/wiki/File:Mediawiki_sunflower.pdf

localurl: /wiki/File:Mediawiki_sunflower.pdf