BEFORE I START: I'M ONLY USING JAVASCRIPT
在我开始之前:我只使用JAVASCRIPT
I try to find the relative image path used on this page (I want it to be dynamic per item name). I found this link http://2007.runescape.wikia.com/wiki/File:Abyssal_whip.png where the image is placed on the wikia. the only thing is I want this image found on the same link:
我试图找到此页面上使用的相对图像路径(我希望它是每个项目名称的动态)。我找到了这个链接http://2007.runescape.wikia.com/wiki/File:Abyssal_whip.png,其中图像放在wikia上。唯一的问题是我想在同一个链接上找到这个图像:
When I click that image I come to this link: http://img2.wikia.nocookie.net/__cb20130726060939/2007scape/images/5/5c/Abyssal_whip.png
当我点击该图片时,我来到这个链接:http://img2.wikia.nocookie.net/__cb20130726060939/2007scape/images/5/5c/Abyssal_whip.png
Is there any way to retrieve this specific path by giving in this link?: http://2007.runescape.wikia.com/wiki/File:Abyssal_whip.png
有没有办法通过提供这个链接来检索这个特定的路径?:http://2007.runescape.wikia.com/wiki/File:Abyssal_whip.png
I hope someone comes up with any ideas on how to achieve this, as I can't seem to find a proper way to fix this problem.
我希望有人提出如何实现这一点的任何想法,因为我似乎无法找到解决此问题的正确方法。
If you have any further questions on this please let me know.
如果您对此有任何疑问,请告诉我。
EDIT: This did the job for me http://2007.runescape.wikia.com/wiki/Special:Filepath/Abyssal_whip.png
编辑:这为我完成了这项工作http://2007.runescape.wikia.com/wiki/Special:Filepath/Abyssal_whip.png
Result:
结果:
1 个解决方案
#1
2
Method 1:
方法1:
There is a magic word to get an absolute path to a file: {{filepath}}
有一个神奇的词来获取文件的绝对路径:{{filepath}}
In your case you would do:
在你的情况下,你会做:
{{filepath:Abyssal_whip.png}}
...or to get the path to a 300px wide thumbnail:
...或者获得300px宽缩略图的路径:
{{filepath:Abyssal_whip.png|200}}
This will give you a protocol relative, absolute path to the file (e.g. //img2.wikia.nocookie.net/[…]/Abyssal_whip.png
).
这将为您提供文件的协议相对绝对路径(例如//img2.wikia.nocookie.net/[...]/Abyssal_whip.png)。
There is no straightforward way to get the relative path to a file (and I really can't imagine why you would need that). You can parse the string, removing the first part, if the images are always at the same server (i.e. you are not using Wikimedia Commons or any other external image repositories. Not sure if Wikia has that enabled or not), using Extension:ParserFunctions (installed at Wikia). It would look something like this:
没有直接的方法来获取文件的相对路径(我真的无法想象你为什么需要它)。您可以解析字符串,除去第一部分,如果图像是总是在相同的服务器,使用扩展(即不使用维基共享资源或任何其他外部图像库不知道维基已是启用。):ParserFunctions (安装在Wikia)。它看起来像这样:
{{#replace:{{filepath:{{{image|}}}}}|//img2.wikia.nocookie.net/[…]|}}
Method 2:
方法2:
There is a special page called Special:Filepath
, that will give you the path to any file. Once again, you will only get the absolute path, so not really what you asked about. In your case http://2007.runescape.wikia.com/wiki/Special:Filepath/Abyssal_whip.png
redirect to the actual file. You should be able to use this for links, or in scripts.
有一个名为Special:Filepath的特殊页面,它将为您提供任何文件的路径。再一次,你只会得到绝对的路径,所以不是你所要求的。在您的情况下http://2007.runescape.wikia.com/wiki/Special:Filepath/Abyssal_whip.png重定向到实际文件。您应该能够将其用于链接或脚本。
#1
2
Method 1:
方法1:
There is a magic word to get an absolute path to a file: {{filepath}}
有一个神奇的词来获取文件的绝对路径:{{filepath}}
In your case you would do:
在你的情况下,你会做:
{{filepath:Abyssal_whip.png}}
...or to get the path to a 300px wide thumbnail:
...或者获得300px宽缩略图的路径:
{{filepath:Abyssal_whip.png|200}}
This will give you a protocol relative, absolute path to the file (e.g. //img2.wikia.nocookie.net/[…]/Abyssal_whip.png
).
这将为您提供文件的协议相对绝对路径(例如//img2.wikia.nocookie.net/[...]/Abyssal_whip.png)。
There is no straightforward way to get the relative path to a file (and I really can't imagine why you would need that). You can parse the string, removing the first part, if the images are always at the same server (i.e. you are not using Wikimedia Commons or any other external image repositories. Not sure if Wikia has that enabled or not), using Extension:ParserFunctions (installed at Wikia). It would look something like this:
没有直接的方法来获取文件的相对路径(我真的无法想象你为什么需要它)。您可以解析字符串,除去第一部分,如果图像是总是在相同的服务器,使用扩展(即不使用维基共享资源或任何其他外部图像库不知道维基已是启用。):ParserFunctions (安装在Wikia)。它看起来像这样:
{{#replace:{{filepath:{{{image|}}}}}|//img2.wikia.nocookie.net/[…]|}}
Method 2:
方法2:
There is a special page called Special:Filepath
, that will give you the path to any file. Once again, you will only get the absolute path, so not really what you asked about. In your case http://2007.runescape.wikia.com/wiki/Special:Filepath/Abyssal_whip.png
redirect to the actual file. You should be able to use this for links, or in scripts.
有一个名为Special:Filepath的特殊页面,它将为您提供任何文件的路径。再一次,你只会得到绝对的路径,所以不是你所要求的。在您的情况下http://2007.runescape.wikia.com/wiki/Special:Filepath/Abyssal_whip.png重定向到实际文件。您应该能够将其用于链接或脚本。