1

I'm creating a wiki (using MediaWiki) which pulls data from a mySQL instance, and uses this alongside a template to generate the page dynamically.

My mySQL instance contains images, stored in a field of type BLOB.

Is it possible for MediaWiki to interpret this BLOB data into the actual image desired to be shown on the page?

  • Why introduce a wiki into this scenario? Wikis are great when you invite the public to edit. It sounds like you have a different use case entirely. – Stephen Ostermiller Jun 20 '17 at 13:06
  • The use case in this instance, is to have a database, for which the wiki is a front-end to accessing some aspects of the data. Data may be contributed to the wiki, which is then reviewed and added to the database in a batch basis. The number of users and data is manageable (small). :-) – Masutatsu Jun 20 '17 at 13:10
  • It is certainly possible to pull image data out of a database and serve it as in image. It is just a matter of setting the correct Content-Type headers. I doubt that MediaWiki has this type of functionality built in, however. The documentation I've looked at indicates MediaWiki usually keeps images in the file system. – Stephen Ostermiller Jun 20 '17 at 13:11
  • Hi Stephen, thanks for your help so far! I was going to use the plugin ExternalData (mediawiki.org/wiki/…) to get the data, but I cannot see anything referencing BLOBs, or content-headers. Does this mean I'm completely, per se, screwed trying to do this? – Masutatsu Jun 20 '17 at 13:15
  • I don't know enough about MediaWiki to answer your questions about how flexible it is. – Stephen Ostermiller Jun 20 '17 at 14:50
1

One way to do it is to write a FileBackend subclass for using the DB as a backend. There is not much documentation on how to do it, though. (This would assume that you still store the names of files in the wiki DB, and only use your custom DB to store file contents. If you want to delegate all file handling responsibility to the custom DB, you'll also need your own file repo class as well. Also not well documented; see $wgForeignFileRepos as a starting point.)

A less elegant but easier approach is to write a tag extension which takes an image name/id and outputs the HTML for the image, maybe as a data: URI (or using a special page as the src and doing the DB lookup there). You'll have to reimplement all the image handling (HTTP headers, HTML formatting etc) that MediaWiki would otherwise do for you, though.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.