Reputation: 1761
I would like find the exact URL for an image in mediawiki to send in my pinterest code. To find the page URL I use urlencode($wgTitle->getFullURL()) but I can't figure out what code to use for image and image description. Thanks
Upvotes: 5
Views: 3455
Reputation: 780
You can link to the page /wiki/Special:Filepath/File_name
or /wiki/Special:Redirect/file/File_name
, that will redirect the request to the full image location, for example: https://en.wikipedia.org/wiki/Special:Filepath/Turtle.jpg redirects to the full image path https://upload.wikimedia.org/wikipedia/commons/6/60/Turtle.jpg
Upvotes: 1
Reputation: 664237
To get the filepath in a wiki page, you can use [[Special:Filepath]]
, the {{filepath:...}}
parser function or a link to the Media
namespace.
To get it programmatically with PHP, you might want to have a look at How does MediaWiki calculate the file path to an image? or the code of the filepath function:
$file = wfFindFile( $filename );
$url = $file->getFullUrl();
(getFullUrl()
method in the File
class)
For your use case you might also have a look at the Extension:AddThis, they plan to support Pinterest too.
Upvotes: 4