Implement and make use of 'query_replace' template tag.

Removes need to hard-code full length replacement query hrefs throughout.
Also allows us to use a query key to choose whether to show thumbnails,
dropping the javascript. (Fixing issue #4865)
Neater Http query boolean inversion.
Merge pull request #19 from timstaley/query-replace

Implement and make use of 'query_replace' template tag.