wordpress的gallery的用法语法
之前写抗美援朝纪念馆的时候,附加了大量图片,就仔细研究了一下WordPress的shortcode gallery的语法。我属于不喜欢装插件的,虽然有很多方便的插件可以用来显示图片。如果你想在某一篇post显示图片,用gallery无疑是最方便的,不仅仅代码少,而且易于控制。下面是翻译自Using_the_gallery_shortcode的文章,不对之处请提出。我附上了原文。以防误读。
Gallery Shortcode
Gallery 短码
In WordPress 2.5, the Gallery feature allows the option to add an image gallery to a Post or Page on your WordPress blog.
The shortcode is used in a Post or Page to display a thumbnail gallery of images attached to that post. It can be used in its simplest form like this:
在wordpress2.5中,Gallery功能允许选择和添加一副图片到wordpress的帖子或者页面。Gallery短码常用于在一篇帖子或者页面中显示它本身附带的图片的缩略图,经常以如下的形式运用:
There are several options that may be specified using this syntax:
Gallery的选项通过以下语法标记。
You can also print a gallery directly in a template like so:
你也可以把Gallery直接放在模板中显示图片,语法如下:
< ?php echo do_shortcode(''); ?>
Options
The following basic options are supported:
选项:
下面是Gallery支持的选项。
columns
specify the number of columns. The gallery will include a break tag at the end of each row, and calculate the column width as appropriate. The default value is 3. If columns is set to 0, no row breaks will be included. For example, to display a 4 column gallery:
分栏
指定分栏的数目,Gallery将在每一行的结尾包括一个中断符,并且计算合适的分栏宽度。默认的值是3,如果设置成0,就不会包括中断符,例如下面是显示4栏。
译者说明,如果你想让你的图片居中显示,把columns的值设定成1就可以了。如下
id
specify the post ID. The gallery will display images which are attached to that post. The default behaviour if no ID is specified is to display images attached to the current post. For example, to display images attached to post 123:
id
指定帖子的id,Gallery讲可以显示附加在这篇id下面的图片。默认没有id,显示本帖下面附加的图片,如下面显示帖子123中附带的图片。
size
specify the image size to use for the thumbnail display. Valid values include “thumbnail”, “medium” and “full”. The default is “thumbnail”. For example, to display a gallery of medium sized images:
大小
指定图片的大小,用于缩略图的显示。他的值包括”thumbnail”, “medium” and “full”,代表缩略图,中等大小,和全副显示,默认值是thumbnail。例如下面是以中等大小显示图片。
Some advanced options are available:
还有一些高级的选项如下:
orderby
specify the sort order used to display thumbnails. The default is “menu_order ASC, ID ASC”.
指定缩略图的显示顺序,默认是”menu_order ASC, ID ASC”,降序排列。
itemtag
the name of the XHTML tag used to enclose each item in the gallery. The default is “dl”.
XHTML的标签名字包括在gallery的每一项中。默认是”dl”。
icontag
the name of the XHTML tag used to enclose each thumbnail icon in the gallery. The default is “dt”.
XHTML的标签名字包括在gallery的缩略图的每一项中。默认是”dt”。
captiontag
the name of the XHTML tag used to enclose each caption. The default is “dd”. For example, to change the gallery markup to use div, span and p tags:
XHTML的标签名包括在每一个标题中,默认是”dd”。
转载原创文章请注明,转载自:未知的味觉[http://www.wangyutang.com]
本文链接: http://www.wangyutang.com/2008/12/wordpresss-gallery-shortcode-syntax/