Pergunta

I am attempting to make an image link to an upload form that will allow a user to upload the image with a particular name. I have a series of pages with a "Person" infobox on them. If no picture has been supplied, I use a placeholder image that is just a stick figure. I would like to set it so that clicking on the image will take the user to an upload form that has a file name already filled in based on the pagename. The problem is that the use of {{PAGENAME}} inside of the template is breaking the link for some reason.

Person Infobox Template (just the part that matters):

 [[image:PlaceHolder.jpg|300px|link=http://www.MyWiki.com/index.php?title=Special:Upload&wpDestFile={{PAGENAME}}.jpg]]

This doesn't work at the moment... The goal here is to have it work something like this link where "John Smith" is the name of the page the template is placed on: http://en.wikipedia.org/wiki/Special:Upload?wpDestFile=John Smith.jpg. (Note that the destination filename is filled in with "John Smith.jpg"

Foi útil?

Solução

Figured it out. The issue was with there being a space in the name of the page. That is why it was working on some pages and not on others.

Here is the fix (it removes any spaces, so "John Smith" becomes "JohnSmith":

.../index.php?title=Special:Upload&wpDestFile={{#replace:{{PAGENAME}}| |}}.jpg

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top