.@PAGE@
as the second parameter, is the namespace where the uploaded image will go. But this namespace contains an @PATTERN@
. This introduces some dynamic behavior. @PAGE@
gets replaced with the page name of the page that will be created. The list of replacements is available on the bureaucracy page. Let's say I create a page for me, schplurtz, then .@PAGE@
turns into .schplurtz
. .
means "the namespace of the page". So we finally get "the namespace schplurtz
in the namespace where the page is created". I could have used users:@PAGE@
or even simpler, @ID@
, to get the same result, since @ID@
is replaced by the full page id, ie :users:schplurtz
in my example. In the end, for each page that is created, this will create a namespace with the same name alongside the page. Why do I create one namespace per page ? imagine I want to upload a file called avatar.png
, and that you also want to upload a file by the same name. If we don't create a namespace for each page, there will be a conflict. With this technique, I get the page users:schplurtz
, my avatar as users:schplurtz:avatar.png
, and you'd have your page users:feathers
, your avatar being users:feathers:avatar.png
. Two files with same name in different namespace ; no problem.
The third parameter is a constraint. /.(png|jpe?g|gif|svg)$/
is a regexp -- some kind of text formula -- that's used to limit what can be uploaded. Note that there is an error in the formula. It should be /\.(png|jpe?g|gif|svg)$/
. This one allows only files whose name ends in .png
, .jpg
, .jpeg
, .gif
and .svg
. So hopefully nobody will upload a zip, exe, or whatever file they have at hand. I'm not giving more details here as regexps are powerful but really complex. The Bureaucracy page has a quick course on regexp.