WordPress: Function Reference/wp get attachment url:修订间差异

来自站长百科
跳转至: 导航、​ 搜索
无编辑摘要
无编辑摘要
 
第1行: 第1行:
==描述 ==
==描述 ==
Returns a full URI for an [[WordPress:Using_Image_and_File_Attachments|attachment file]] or <var>false</var> on failure.


返回[[WordPress:Using_Image_and_File_Attachments|附属文件]]完全URI或者没有URI,返回<var>false</var>
返回[[WordPress:Using_Image_and_File_Attachments|附属文件]]完全URI或者没有URI,返回<var>false</var>


<!-- Wordpress uses this function to generate a link when you insert an attachment into a post and choose <tt>Linked to file</tt>. -->
<!—当你向一篇文章插入附件,并且选择<tt>链接到文件</tt>的时候,Wordpress使用这个函数,产生一个链接-->
 
<!—当你向一篇文章插入附属设置,并且选择<tt>链接到文件</tt>的时候,Wordpress使用这个函数,产生一个链接-->
 
== Example usage & output ==


== 例子用法 &输出 ==
== 例子用法 &输出 ==
%%%<?php echo wp_get_attachment_url(12); ?>%%% outputs something like <tt><nowiki>http://wp.example.net</nowiki>/wp-content/uploads/<var>filename</var></tt>


%%%<?php echo wp_get_attachment_url(12); ?>%%% 产出内容像<tt><nowiki>http://wp.example.net</nowiki>/wp-content/uploads/<var>文件名</var></tt>
%%%<?php echo wp_get_attachment_url(12); ?>%%% 产出内容像<tt><nowiki>http://wp.example.net</nowiki>/wp-content/uploads/<var>文件名</var></tt>
== Parameters ==


== 参数 ==
== 参数 ==
{{Parameter|id|integer|The ID of the desired attachment|required}}
{{Parameter|id|integer|需要的附属内容的ID|required}}
{{Parameter|id|integer|需要的附属内容的ID|required}}
== Related ==


==相关的==
==相关的==
== Description ==
== 描述 ==
== 描述 ==
You can change the output of this function through the [[WordPress:Plugin_API/Filter_Reference#Link_Filters|wp_get_attachment_url]] filter.


你可以通过[[WordPress:Plugin_API/Filter_Reference#Link_Filters|wp_get_attachment_url]]过滤器更改这个函数的输出。
你可以通过[[WordPress:Plugin_API/Filter_Reference#Link_Filters|wp_get_attachment_url]]过滤器更改这个函数的输出。
If you want a URI for the [[WordPress:Templates_Hierarchy#Attachment_page|attachment page]], not the attachment file itself, you can use [[WordPress:Template_Tags/get_attachment_link|get_attachment_link]].


如果你想要[[WordPress:Templates_Hierarchy#Attachment_page|附属网页]]的URI,而不是附属文件本身,你可以使用[[WordPress:Template_Tags/get_attachment_link|get_attachment_link]]。
如果你想要[[WordPress:Templates_Hierarchy#Attachment_page|附属网页]]的URI,而不是附属文件本身,你可以使用[[WordPress:Template_Tags/get_attachment_link|get_attachment_link]]。

2008年7月25日 (五) 09:31的最新版本

描述[ ]

返回附属文件完全URI或者没有URI,返回false

<!—当你向一篇文章插入附件,并且选择链接到文件的时候,Wordpress使用这个函数,产生一个链接-->

例子用法 &输出[ ]

%%%<?php echo wp_get_attachment_url(12); ?>%%% 产出内容像http://wp.example.net/wp-content/uploads/文件名

参数[ ]

相关的[ ]

描述[ ]

你可以通过wp_get_attachment_url过滤器更改这个函数的输出。

如果你想要附属网页的URI,而不是附属文件本身,你可以使用get_attachment_link