mediawiki mediaviewer and file: pages

The purpose here is to propose a simple way to have file: or media pages for Pmwiki, plus a few tests to see if some of the ideas work.

Upload template page

This template would include PageTextVars that hold all the information about a file.

Example png file
CC 2.0
Example image file from
Example image file
Example image file
Example image file
The example Image
The example Image
The example Image
The example Image



Perhaps the vars should be placed on top and with hidden PageTextVars (:var:val:) and referenced after on any of the templates, both for the "file page" as too the embbeded media files on pages.

With embbeded files on pages, using a template for a gif file, it would include:

  • the gif file as a thumb
  • template specific width and height set on template,
  • or width and height from the MediaVars on top
  • a caption
  • a link to the file page
  • a link to a theater mode or carroussel perhaps
  • background color
  • border color and thickness,
  • and so on

Vars can be accessed trough :

Within the page:


From another page;


it could also be:


and so on ...

After trying to achieve a big nested conditional in Pmwiki markup, to check MediaExtension and RecipeVersion index and starting a viewer according to extension, I believe it would be best to create a markup for that, like:

 (:mediaviewer type={$:MediaType} file={$:MediaLocation} fmt=simple :).

There are things that can be done inside a specific markup, like :

  • file finger printing can be used and checked
  • check extension with finger print
  • choose template to use
  • cerate specific vars that can be passed on to the template

Other: The templates can include a call to the viewers, so mediaviewer markup would be just a include helper.

Here is an example using conditionals and a new condition type:

$Conditions['recipeexists'] = "RecipeExists(\$pagename,\$condparm)";

(:if [ equal png {$:MediaType} and recipeexists pngviewer ] :)

   (:mediaviewer type={$:MediaType} file={$:MediaLocation} fmt=zoomable :)

(:elseif [ equal gif {$:MediaType} and recipeexists gifviewer ] :)

   (:mediaviewer type={$:MediaType} file={$:MediaLocation} fmt=zoomable :)

(:elseif [ equal png {$:MediaType} and recipeexists pngviewer ] :)

   (:mediaviewer type={$:MediaType} file={$:MediaLocation} fmt=zoomable :)


 $[Sorry, we don't have a viewer for this file type]


AttachMedia or MediaAttach: should have its templates inside "Site/" for each file type teh same use by mediaviewer.

In the end Mutimedia Viewer is just a quick visualization of the information contained in file: pages, created dynamically with javascript upon a click on a media file AFAIK.

The page has some information about a media file, be it pdf,png,gif,mp4,mp3,mpeg,avi,3gp and many others.

As written above with PmWiki Markup, we have a general definition list for any media type, delivered blank upon a upload action request, in a form input box with variables that can hold information for any kind of media.

The only thing that is missing is a way to visualize each media file, as the media files will be uploaded to a specific folder defined in the UploadFmt or UploadDirFmt, and the file location will be referenced in $:MediaLocation

MediaViewing could also be achieved creating a series of conditionals inside the template to properly show a media viewer for each type of media as shown above.

The information displayed or collected , can change or evolve easily, as you just have to change the upload form template and add new formatting, variables, fields and viewers.

Here is a list of the information displayed and also actions available on a file: page for mediawiki:

reference page: reference page:


  • close - more for the dinamic mediaviewer in javascript
  • full screen view - can be achieved with javascript or without it
  • enable/disable media viewer - more of an option for the javascript dynamic viewer
  • download media
  • share or embed media - can be easily done with templartes
  • change resolution of images and videos - should be made by other recipes and enable as an integration upon enablement.

Info Sections

  • original file size - perhaps can be informed by the user or implement in the upload script
  • original resolution of images and videos - same as above
  • structured data - one line info about file
  • summary : description,date,source,author
  • licensing : big box explaining the situation of the media file regarding licensing and rights granted to it
  • file history : shows changes made to a file, perhaps we can use page history for that
  • file usage in this wiki - we can keep track of file usage creating an new markup like AttachMedia: or MediaAttach: or even (:mediaviewer:)
  • file usage on other wikis - same as above
  • metadata: information stored inside the files, like geo, software name and version and other metadata, should be made by other recipes and enabled as an integration

Obs: Resource heavy and more specific actions should be easily integrated with just a RecipeVersion checking and enablement of recipes

Obs2: MediaAttach: or AttachMedia:, or even a (:mediaviewer:) would just reference the Media Page and a format would already be made for that media, organizing all the information collected upon a upload and a standard per media formatting, including all information and available actions also on a per media basis and recipe enablement basis. It would be all based on templating and special cases could be addressed as well with new templates for the directive trough the "fmt=" attribute/option.

Obs3: I believe some information should be already available and replaced on a template call, just like ROS or ROE, perhaps use ROE with a especial array of transformations or if not available already, using PageTextVars or just PageVars like : {$TimeISOFmt}, {$Pagename}, {$Author} and so on.

Please be free to write suggestions or correct me.

Off topic

  1. ROP in PHP
  2. Var sanitization
  3. whitelist programming
 0: 00.00 00.00 config start
 1: 00.01 00.01 config end
 2: 00.21 00.21 MarkupToHTML begin
 3: 00.27 00.26 MarkupToHTML end
 4: 00.28 00.26 MarkupToHTML begin
 5: 00.28 00.27 ReadApprovedUrls SiteAdmin.ApprovedUrls begin
 6: 00.29 00.27 ReadApprovedUrls SiteAdmin.ApprovedUrls end
 7: 00.29 00.28 MarkupToHTML end
 8: 00.29 00.28 MarkupToHTML begin
 9: 00.30 00.29 MarkupToHTML end
10: 00.30 00.29 now
Peak memory: 3,933,504 bytes