WordPress:Using Image and File Attachments

来自站长百科
Xxf3325讨论 | 贡献2008年6月16日 (一) 10:24的版本
跳转至: 导航、​ 搜索
可打印版不再被支持且可能有渲染错误。请更新您的浏览器书签并改用浏览器默认的打印功能。

This article is [[WordPress::Category:Copyedits|marked]] as in need of editing. You can help Codex by editing it.

在WordPress2.5中,媒体管理功能大大地提高了。你可以直接只用编辑工具条上的按钮来管理你当前的文件,并且上传新的文件。

使用图像和文件附加装置有一个指南,对于WordPress2.5中的图像和文件附加装置的功能性有一些疑问。这个指南要回答以下的问题:

  1. 图像和文件附加装置是如何运行的?
  2. 我怎样使用这个功能?
  3. attachment.php模板网页是关于什么的?

上传文件的必要条件

为了要使用所有的这些工具,你需要将wp-content文件夹的权限改为777。如果你没有改变权限,来在wp-content文件夹中编写,你就不能使用 uploader。如果你不知道怎样更改这个值,请阅读改变文件权限

图像和文件附加装置在WordPress2.5文档中是怎样运行的

在以前版本中相互分开的标签,在WordPress2.5中已经由一个编辑器工具条中完全结合在一起的标签代替了。"添加 媒体"部分包含了四个按钮:添加图像,添加视屏,添加音频,添加媒体。当你点击添加图像的时候,你就会看到一个面板,你可以在这个面板上选择是否要从图像集(当前文章中的图像)上传一个图像,还是从媒体图书馆(任何文章或者网页上上传的图像)上传图像。

也有一个媒体图书馆部分,在这个部分,你可以浏览,编辑,和删除媒体文件(但是不能添加文件)。

在WordPress2.0文档中图像和文件附加装置是怎样运行的

许多用户的评论指出,这些用户在写博客文章的时候,使用"上传"标签来上传图像或者文件,但是很疑惑,为什么这些附加装置没有出现在他们的博客中。博客作者需要注意的一些事项:

  1. 文章编辑窗口下面的区域是一个文件图书馆,能使你上传并且浏览上传的文件和图像。只有你真正地将文件和图像插入到文章中,它们才会变为"附加装置"。因此,称这些图像和文件为附加装置是不妥当的;称它们为"嵌入的文件"更加确切。
  1. 在"浏览" 或者 "浏览所有的" 标签(它的功能就像可以浏览的上传文件集)上点击极小的东西,你就能够得到插入图像和文件链接到你的文章上的选项。你点击之后,就会出现一个弹出的"菜单",这个菜单上有toggles,会显示用什么样的hyperlink来包装图像或者链接进的文件,以及真正插入的图书馆条目。
  1. 根据你从上述的弹出"菜单"中选择什么选项(而且我们非常宽松地使用了这个术语,因为它没有像,就如你以下所看到的,一个典型的弹出菜单那样运行),插入的内容可能或者可能不适用你的attachment.php模板文件。如果从弹出的菜单中选择了合适的选项,就如以下所讨论的,一个访客点击了博客文章中的一个条目,就会来到attachment.php模板文件设计的一个网页中,前提是这个文件存在于你使用的主题中。

完整的用法指示说明

这些指示说明的运行是假定你在你的WordPress站点的管理后台。

1)要创建一个新的博客文章,点击"写。"要编辑一篇当前的文章,点击"管理"并且点击当前文章旁边的"编辑"。

2)在文本编辑器窗口的下面,你应该看到一个部分,这个部分的标题是"上传"。如果你想要添加到博客文章上的文件/图像在先前的文章中已经上传了,你只是想再次地使用这个文件/图像,那么你在"上传" 的旁边会看到一个标签,标签标着"浏览所有的"。 点击这个标签,然后点击跳到第10步

3)点击"浏览"并且在你的本地电脑上找到文件。建议你使你的文件名"符合服务器"要求,要确定文件名没有空格,省略号,斜线或者其它的非文字数字的符号($,%,&, etc.),如果文件含有这些符号的话,在文件上传之前,从新命名文件。

4)在你的电脑上选择文件,就如你导航到并且在文字处理系统中打开一个文件,并且点击"打开。"对话框就会关闭,而且文件名会在"文件"的旁边填写。

5)在标题类型下,有一个文件的简短的,易懂的英语标题。

6)在描述类型的下面有一个稍微长一点的,更加详细的关于文件是什么的描述。

7)点击"上传。"

8)你现在可以看到浏览标签,突出地显示在"上传"的旁边。如果你想的话,你可以点击,返回到"上传"并且上传更多的文件。如果你完成了,点击,返回到"浏览。"

9)现在不管你上传了什么文件/图像,这些文件,图像都在网络浏览器上,等着你去使用。如果你点击了"浏览",浏览器会显示所有的文件,相关程序判断这些文件与这篇文章相关(不过你已经上传了什么文件

10)现在你向文章中插入图像和文件。对于插入图像,请看看下面的"插入 图像"。对于插入文件,请看看下面的"插入文件。"

插入图像

在图像上点击一次。会出现一个小的弹出的菜单。大多数菜单内容是一个toggle switch,在你添加图像到你的文章之前,能使你选择不同的选项。例如,点击"使用Thumbnail",就会转到"使用 最初的。"点击"使用 最初的",那么它就会返回到"使用Thumbnail。"下面是不同选项的解释:

  1. 使用 Thumbnail会向你的文章插入一个图像的极小的版本。
  1. 使用 最初的会将图像以原始的大小插入到文章中。(注如果原始图像大小非常的小,thumbnail 版本可能会更大一点!)如果你在标题框中输入了文本,那么这个文本就会作为图片的替换文本出现。描述区域的文本不会出现在编码内,这个编码使得图像显示了。
  1. 没有链接到指的是图像只会出现在文章中,图像上没有任何的hyperlink(如果一个访客点击了图像,访客不会进入其它的网页。)
  1. 被链接到图像指的是图像上有一个hyperlink,因此如果一个 访客点击图像,访客就会来到一个空白的浏览器网页,这个网页包含了原始大小的图像(即使你选择了"使用 Thumbnail," 这只适用于真正的博客文章)。如果你有一个非常大的图像, 这个特别有用,因为你可以使用文章中的一个thumbnail,但是使得这个thumbnail链接到一个完整大小的图像。如果你在标题区输入文本,这个文本会用来描述链接(当你在一些浏览器中的链接上盘旋的时候,这个文本就会出现)。
  1. 被链接到网页会在图像上置入一个hyperlink,如果访客点击这个hyperlink,访客就会进入一个布局优美的博客页面,这个页面特写了图像。如果你在标题区输入了文本,这个文本就用来描述链接(当你的鼠标在一些浏览器的链接上盘旋的时候,文本就会出现)如果你在描述区输入了文本,这个文本就会在文章内容中出现,就像普通的文章内容。牢记因为这个网页会像其它的网页那样地布局,如果图像太宽了,图像可能会因为太宽而"破坏了" 一些主题的网页的布局因此如果你有一个特别宽的图像,考虑使用"被链接到图像" 而不是"被链接到网页。"
    (这样,你可以将"被链接到网页"看做是一个缩短的短语,所指的意思是"链接到一个standalone,可应用主题的博客网页,这个博客网页本身也包含有链接,能够连接到真正的内容。"对于一个弹出的菜单,有一点太长了。)
    同时也要知道,如果你使用"被链接到网页"这不仅会为图像创建一个新的小的博客网页 (如上所述,使用描述区文本),还会允许访客在文章中,单独地评论。因此,你可以以这种方式来要求评论图像
  1. 发送到编辑器带着你选择的这些选项,然后将图像插入鼠标指针所在的编辑器窗口。
  1. 删除会在服务器中将所有的文件删除。
  1. 关闭 选项关闭了小的弹出菜单。与大多数弹出菜单不同,它不会自己离开,因此在你插入图像的时候,点击关闭选项

2.1.x版本的注意事项

在这个版本以及更新的版本中,不再有"弹出 菜单"。点击这些图像,会显示一个列表,这个列表上有单选按钮选项,这些选项与上面所描述的相似。

插入文件

Click once on the file name. A small popup menu appears. The program attempts to deduce what kind of file it is; for example if you upload a .DOC file (Microsoft Word file) it will read that and say "File Type: application/msword" at the top, which is in this case a successful guess at what the file is.

点击文件名。会出现一个小的弹出的菜单。程序试图要推导出这是什么样的文件;例如,如果你上传了一个.DOC文件(Microsoft Word 文件),程序会阅读这个文件,并且在顶端显示"文件 类型: 应用/msword",这是程序对于文件的正确的判断。

Most menu items are a toggle switch that allows you to select various options before actually adding the image to your post. For example, click "Linked to File" and it will turn to "Linked to Page." Click "Linked to Page" and it will toggle back to "Linked to File." Here are the explanations of the various options:

大多数菜单选项是拨动开关,能使你在真正地给你的文章添加内容之前,选择不同的选项。例如,点击"链接到文件" ,它会转到 "链接到网页。"点击"链接到网页",它又会返回到"链接到文件。"下面是不同选项的解释:

  1. Linked to File means that when a visitor clicks on the link that you insert when you hit "Send to Editor," they will be taken directly to the file in question (and most likely prompted to download it, depending on the user's browser and system settings).
  1. 链接到文件指的是当一个访客点击了你插入的链接的时候,你点击"发送到编辑器,"访客就会直接来到正被讨论的文件(根据用户的浏览器和系统设置,很有可能会下载这个文件)
  1. Linked to Page means that when a visitor clicks on the link, they will be taken to a blog page featuring the filename and its title and description--basically adding an extra layer between the blog posting and the actual download of the file.
    (In this way, you can consider "Linked to Page" to be a shortened phrase meaning "Linked to a standalone, themable blog page which itself contains the link to the actual content." A little too long for a popup menu.)
    Also consider that if you use "Linked to Page" it will not only create a new little blog page for the file download, it will also allow visitors to comment on it separately from the post. So you can solicit comments on a file in this way.
  1. 被链接到网页指的是当一个访客点击链接的时候,他们就会来到一个网页,这个网页上有文件名和标题和描述—一般在博客文章和真正下载的文件之间有一个额外的layer。
    (这样,你可以将"链接到网页"看做是一个缩短的短语,这个短语的意思是"链接到一个standalone, 可应用主题的博客网页,这个网页本身含有链接,连接到真正的内容。" 对于弹出的菜单,有点太长了。)
    同时要知道,如果你使用"链接到网页" 它不仅会为下载的文件创建一个新的小的博客网页,还允许访客在文章上分开地对其讨论。因此你可以以这种方式要求文件上的评论。
  1. Using Title will use, for the text it inserts in the blog entry, the title you typed next to "Title" when uploading the file.
  1. 使用标题会为插入在博客文章中的文本,使用你上传文件时,在"标题"旁边输入的标题。
  1. Using Filename will use the actual filename. So if you uploaded a file named "thisdocument.pdf" and gave it a Title of "New Product Brochure" when uploading, then it will insert "New Product Brochure" into the blog entry if you pick "Using Title" and will insert "thisdocument.pdf" if you pick "Using Filename." No matter which you use (and Using Title is strongly recommended for readability) it will still link to the actual filename when clicked on.
  1. 使用 文件名会使用真正的文件名。因此,如果你上传了一个命名为"thisdocument.pdf"的文件,你上传这个文件的时候,给这个文件的标题是"新产品手册",那么如果你选择"使用 标题",文件会将"新产品手册"插入到博客文章中,如果你选择"使用 文件名",它会插入"thisdocument.pdf"。不管你使用什么(因为易读性方面的原因,强烈推荐使用标题),点击的时候,它仍然会链接到真正的文件名。
  1. Send to Editor takes those options you selected and then inserts the hyperlinked text into the editor window wherever the cursor was. Thus, unlike with images, it simply creates a clickable hyperlink to the file.
  1. 发送到编辑器带着你选择的这些选项,并且在鼠标指针所在的编辑器窗口中插入hyperlinked文本。因此,与图像不同,它只是给文件创建了一个可以点击的 hyperlink
  1. Delete will remove the file from the server entirely.
  1. 删除会移除服务器上的所有文件。
  1. Close Options closes the little popup menu. Unlike most popup menus it will NOT go away by itself, so click this when you're done inserting the image.
  1. 关闭 选项关闭了小的弹出菜单。与大多数弹出菜单不同,它不会自己离开,因此但你完成了插入图像之后,点击这个。

Once you have selected the options you want and clicked "Send to Editor," the image or file title should appear in the editor window! Be sure to click "Close Options" to close the little popup menu. 一旦选择了你想要的选项,点击"发送到编辑器,"图像或者文件标题应该出现在编辑器窗口中!确定要点击"关闭选项"来关闭小的弹出菜单。


Using in Your Site

在你的站点中使用

You may now wish to go into the attachment.php"template file in your theme folder if you have this file in your theme (or create it if you don't), because you may want to have a custom-styled page for these so-called attachments. Of course, as covered in the instructions above, this will be irrelevant and unnecessary if you never use the Link to Page option when inserting the embedded library item.

你现在可能想要转到你的主题文件夹中的attachment.php"模板文件,前提是你的主题中拥有这个文件(或者如果你没有这个文件,你可以创建一个),因为你可能想要为这些所谓的附加装置创建一个自定义形式的网页。当然,就如指示说明中所提及的,如果你插入嵌入的图集内容时,从来没有使用过链接到网页选项,这就是不相关的,也是没有必要的。

Remember, if you insert items with the "Link to Page" option selected, then not only will the attachment.php template file be called, but on this page comments can be posted completely separately from the actual blog entry. These comments are linked to that attachment, so if you insert (for example) the exact same image into two different posts from the "Browse All" tab, using the "Link to Page" option both times, then people who click into it will get the same page of comments whether they clicked on it from the instance in the first blog entry or the second. (The downside of this is that the attachment still "thinks" it is the child of the original post, so in some attachment.php template files [including the one in the default WordPress theme] that show a breadcrumb trail, it will show the trail as "Post One > Attached Image" even if you clicked on it from "Post Two.") 记住,如果你使用选择的"链接到网页"选项来插入内容,那么不仅仅attachment.php模板文件会得到调用,在这个网页上评论可以在真正的博客文章中完全单独地发表。这些评论被链接到了那个附加装置中,因此,如果你(例如)向"浏览所有的"标签中的两篇不同的文章中插入相同的选项,两次使用了"链接到网页"选项,那么点击这个的访客,会得到相同网页的评论,不管他们是在第一篇博客文章,还是第二篇博客文章中点击,都会得到同样的结果。(这个的下降趋势是附加装置仍然"认为" 它是原始文章的子文本,因此在一些attachment.php 模板文件、 [包括默认WordPress主题中的模板文件] 显示一个breadcrumb trail,会将 trail 显示为 "文章1 > 附加的图像"即使你从 "文章2"中点击,也会出现同样的结果。)

This should serve to clear up some confusion, and revisions are welcome. 这是用来消除一些疑惑,同时欢迎修正。


Additional Notes

附加的注意事项

  • If you are using Mozilla Firefox, you can also drag and drop the file into Post editor. This creates a thumbnail image only, however, and if your blog is NOT in the root folder of your site it may produce a broken link.
  • 如果你正在使用Mozilla Firefox, 你也可以将文件拖放到文章编辑器中。这样只会产生一个极小的图像,但是,如果你的博客不在你的站点的根文件夹上,这个可能会产生一个断掉的链接。
    • If the popup menu doesn't show up, check whether the extension "Adblock" (if installed) is the source for the problem. To do so, temporarily deactivate Adblock and recheck whether the popup menu shows up now. If this is the problem, add your blog to Adblock's white list.
    • 如果弹出的菜单没有显示,查看一下扩展"Adblock"(如果安装了的话)是不是问题的根源。要做到这一点,暂时地取消Adblock的运行,并且重新查看弹出的菜单当前有没有显示。如果这是一个问题,将你的博客添加到Adblock的白色列表上。
  • You can use the white squares in every corner of image to resize your image in your post (however, resize will not change the original file size), or move inside the Post Editor to insert wherever you want it in your post
  • 你可以在你的图像的每个拐角处,使用白色的正方形,在文章中重新地定义图像的大小(然而,重新定义图像大小,并不会更改文件的原始大小),或者将文件移到文章编辑器中,什么时候,向插入,在插入到文章中。
  • If you do not want to use the WYSIWYG editor, and/or you know some HTML; you can use the classic Post editor, letting you modify your HTML directly. If you are not using the WYSIWYG editor:
  • 如果你不想使用WYSIWYG编辑器,并且/或者你知道一些HTML;你可以使用经典的文章编辑器,使你直接地更改你的HTML。如果你没有使用WYSIWYG编辑器:
    1. Click over the file you want to use, and select "Send to Editor" option. The file will go to the Post editor.
    1. 点击你想要使用的文件,并且选择"发送到编辑器"选项。文件就会转到文章编辑器。
    1. You will see the HTML code inserted into your post. You can cut and paste it wherever you want, and modify values such as width or height.
    2. 你会看到HTML代码插入到你的文章中。你可以剪贴并且将这个代码粘贴到任何你想要粘贴的位置,并且更改值,例如width或者height


See also

也看看