Gallery: 模块:imageblock:修订间差异

来自站长百科
跳转至: 导航、​ 搜索
(新页面: =Image Block Module= Makes blocks available to themes for showing random/recent/most-viewed images or albums. ==Description== Show random images or the highlight of the most viewed album...)
 
无编辑摘要
 
(未显示同一用户的2个中间版本)
第1行: 第1行:
=Image Block Module=
=Image Block模块=
Makes blocks available to themes for showing random/recent/most-viewed images or albums.
使得区块可用做外观主题显示随机/最近/访问量最高的图片或相册。


==Description==
==描述==
Show random images or the highlight of the most viewed album or choose between a lot of other image block types to show in a specific album or on all of your Gallery pages. Or show these images on other websites with the external image block.
显示随机的图片或访问量最高的图片的突出,或从一堆其他图片区块类型中进行选择来在某特定相册或所有Gallery页面上显示。或者使用外部图片区块来在其他网站上显示这些图片。


==Features==
==特点==
* Choose between different types of image blocks: random image, recent image, most viewed image, random album highlight, recent album highlight, most viewed album, daily image (changes one time each day), weekly image (changes one time each week), monthly image (changes one time each month), daily album highlight, weekly album highlight, monthly album highlight
* 选择不同类型的图片区块(image block):随机图片,最近访问的图片,访问量最高的图片,随机相册高亮,最近访问的相册高亮,访问量最高的相册,每日图片(每日改变一次),每周图片(每周改变一次),每月图片(每月改变一次),每日相册高亮,每周相册高亮以及每月相册高亮
* Add multiple image blocks
* 添加多个图片区块
* Configure whether to show the title, date, the view counters, ... for each image block
* 为每个图片区块设置是否显示标题,日期,访问计数器
* Additionally, you can choose to show a specific item defined by itemId if you add the block manually in your theme template (theme.tpl, album.tpl, photo.tpl) or if you use the external image block
* 另外,如果在外观主题模板(theme.tpl,album.tpl,photo.tpl)中手动添加了区块或者你使用外部图片区块的话,就可以选择显示某个itemID所定义的特定项目
* Show (random) images of your Gallery on other websites or other pages of your website with the '''external imageblock'''
* 使用'''外部图片区块(external imageblock)'''在其他网站或你网站的其他页面上显示Gallery(随机)图片
* Limit the item selection to the subtree of the Gallery under the album with the given id (only available for manually added image blocks in your template or in external image blocks)
* 限制给定id相册下Gallery子树的项目选择(仅对模板中或外部图片区块中手动添加的图片区块可用)
* Choose a maximum displayed size for the block
* 为区块选择一个最大显示尺寸
* Display full sized images
* 显示全尺寸的图片


==Usage==
==用法==
* Download the module from the download page if necessary. The minimal and typical package of G2 don't include this module.
* 如果需要的话在下载页面中下载此模块。G2的最小安装包及典型安装包中没有包括进此模块。
* Install and activate the module in ''site admin'' -> ''modules''
* ''站点管理(site admin)'' -> ''模块(modules)''中安装并激活此模块。
* '''Configure''' some settings in ''site admin'' -> ''Image Blocks''  
* ''站点管理(site admin)'' -> ''图片区块(Image Blocks)''中进行'''配置'''
* '''Add image blocks''' to your sidebar in ''site admin'' -> ''themes'' -> ''matrix'' (or for any other active/used theme)
* ''站点管理(site admin)'' -> ''外观主题(themes)'' -> ''matrix''(或其他某个激活或被使用的外观主题)的边栏中'''添加图片区块(Add image blocks)'''
* You can configure each image block separately: See [[Gallery:How_To_Setup_Image_Blocks|How to Setup Image Blocks]]
* 你可以单独地对每个图片区块进行配置:参见[[Gallery:How_To_Setup_Image_Blocks|如何安装图片区块(Image Blocks)]]
* Now you and the visitors of your site see the '''image blocks''' in your sidebar in all album / photo pages.
* 现在你以及站点访问者就可以在所有相册或相片页面的边栏中看到'''图片区块(image blocks)'''了。


Also see:
另见:
* [[Gallery:GalleryEmbed:getImageBlock|How to use image block in embedded G2 or as an alternative to the external image block]]
* [[Gallery:GalleryEmbed:getImageBlock|如何在嵌入的G2中使用图片区块或将其作为外部图片区块的一个备用选择]]
* [[Gallery:How_To_Use_The_External_Image_Block_When_url_fopen_Is_Disabled|How to use the external image block when url_fopen is disabled]]
* [[Gallery:How_To_Use_The_External_Image_Block_When_url_fopen_Is_Disabled|在url_fopen禁用的情况下如何使用外部图片区块]]
* [[Gallery:Themes:Reference:Blocks|How to manually add a Image Block in a theme template]]
* [[Gallery:Themes:Reference:Blocks|如何在某个外观主题模板中手动添加一个图片区块(Image Block)]]


== External Options ==
== 外部选项 ==
The following options are available:
以下选项可用:
<pre>
<pre>
blocks      Pipe(|) separate list chosen from:
blocks      竖直分隔线(|)分隔列表:
               randomImage, recentImage, viewedImage, randomAlbum, recentAlbum,
               randomImage, recentImage, viewedImage, randomAlbum, recentAlbum,
               viewedAlbum, dailyImage, weeklyImage, monthlyImage, dailyAlbum,
               viewedAlbum, dailyImage, weeklyImage, monthlyImage, dailyAlbum,
               weeklyAlbum, monthlyAlbum, specificItem; default is randomImage
               weeklyAlbum, monthlyAlbum, specificItem; default is randomImage
show        Pipe(|) separated list chosen from:
show        竖直分隔线(|)分隔列表:
               title, date, views, owner, heading, fullSize, rawImage, none
               title, date, views, owner, heading, fullSize, rawImage, none
itemId      Limit the item selection to the subtree of the gallery under the album with the given id;
itemId      限制给定id相册下Gallery子树的项目选择;
               or the id of the item to display when used with specificItem block type
               或当使用specificItem区块类型时,对要显示的项目id进行限制
maxSize      Scale images to this maximum size. If used alone Gallery will locate the most-closely-sized
maxSize      将图片按比例扩大到最大尺寸。如果单独使用的话,Gallery将会定位尺寸设定最接近的
               image to the specified value - larger images will be scaled down as necessary in your browser.
               图片为定义数值 – 更大的图片则会在你的浏览器中根据需要按比例缩小。
               If specified along with g2_show=fullSize the full size image will always be used and scaled down as necessary.
               如果与g2_show=fullSize一起定义的话,那么全尺寸的图片将总是被使用并根据需要按比例缩小。
exactSize    Just like g2_maxSize except that it will not substitute an image smaller than the size you request,
exactSize    除了不会替换小于所选尺寸的图片之外,它跟g2_maxSize几乎是一样的,
               so you'll get the closest match in size possible. Note that this may use a lot more bandwidth if a much larger
               因此你会获取最接近某特定尺寸的图片。注意如果更大的图片要在浏览器中按比例缩小的话,
               image has to be scaled down in your browser.
               将会占用很多带宽。
link        Href for link on image; value of none for no link; default is link to item in the Gallery
link        Href为图片上的链接;无数值即为无链接;默认为链接到Gallery中的项目
linkTarget  Add a link target (for example, to open links in a new browser window)
linkTarget  添加一个链接目标(例如在新的浏览器窗口中打开链接)
</pre>
</pre>




The maxSize and exactSize parameters may need clarification:
有必要对maxSize和exactSize参量做一个阐述:
* maxSize - Specifying the maxSize parameter for an external image block attempts to intelligently determine the best-sized image to be placed and fill the block.  This was added as a feature to help keep bandwidth usage down for both users and administrators, and to return something that is ''close'' to the requested size.  Previously (and currently, when specified in this fashion) the only use of maxSize was with the fullSize view option.  This yielded gigantic images being returned, but downsized by the browser to fit the size specified by maxSize.  Now, the maxSize parameter can be used separately from the fullSize view option.
* maxSize – 为外部图片区块定义maxSize参量试图智能化地确定尺寸最为合适的图片以填充区块。此特点的加入将帮助用户及管理者有效地降低带宽消耗,并返回与所请求尺寸''相近''的图片。之前(而目前已此方式定义时),maxSize的唯一用处就是与fullSize视图选项一起使用。返回了庞大尺寸的图片,但按maxSize所定义的尺寸被浏览器缩小了。现在maxSize参量可以单独使用了,无需再跟fullSize视图选项一起使用。
<pre>
<pre>
Example Image:
示例图片:
     100px thumbnail
     100px 缩略图
     500px resize
     500px 重设尺寸的图片
     1024px original
     1024px 原始尺寸的图片


maxSize Parameter:
maxSize参量:
     maxSize=299 returns the 100px thumbnail because it is the
     maxSize=299 返回100px的缩略图,因为这是与
       "closest" in size to the requested maxSize. (199px away, whereas
       所请求的maxSize"最接近"的尺寸。(约199px,然而
       the 500px image is 201px away)
       500px的图片约为201px)


     maxSize=300 returns the 500px resize because in the case
     maxSize=300 返回500px的重设尺寸图片,因为在这种情况下,
       of an image having two sizes that are equally close in size
       一个图片具有两种尺寸,而这两种尺寸都同等接近时
       (both 200px away) the larger of the two is returned for quality
       (都约为200px),那么其中稍大的尺寸将应质量需要被选中并返回


     maxSize=800 returns the 1024px original
     maxSize=800 返回1024px的原始尺寸图片
</pre>
</pre>


* exactSize - Just like maxSize except that the image returned will be guaranteed to be downsampled from the next larger size.  This means that you'll never get back an image smaller than the dimensions you specify, except in the case where you specify a dimension larger than the original itself.
* exactSize – 正如maxSize,但除此之外返回的图片会被保证由下一较大尺寸进行向下采样。这意味着你永远不会得到比所定义尺寸稍小的图片,不过定义的尺寸大于原始尺寸图片的情况除外。
<pre>
<pre>
Example Image:
示例图片:
     100px thumbnail
     100px 缩略图
     500px resize
     500px 重设尺寸的图片
     1024px original
     1024px 原始尺寸的图片


exactSize Parameter:
exactSize参量:
     exactSize=299 returns the 500px resize because it is the
     exactSize=299 返回500px的重设尺寸图片,因为这是
       closest larger image.
       最接近的稍大尺寸图片。


     exactSize=500 returns the 500px resize because it is an exact
     exactSize=500 返回500px 的重设尺寸图片,因为这是
       match.
       最符合的。


     exactSize=800 (and anything larger) returns the 1024px original
     exactSize=800 (或更大)返回1024px的原始尺寸图片
</pre>
</pre>






NOTE: Until very recent versions of this module, the "exactSize" parameter did not exist and the "maxSize" parameter did not function as described above.
注:在此模块最新版之前的版本中,"exactSize"参量是不存在的而"maxSize"参量的功能不是如上所述。


I am not certain, but I _believe_ the documents above apply to  version 1.0.11 (which works with Gallery 2.2 RC1) and not to the version of the module that comes with Gallery 2.1.2.
我并不确定,但我认为以上的资料适用于1.0.11版(与Gallery 2.2 RC1兼容)而不适用于Gallery2.1.2所带模块的版本。


== Examples ==
== 举例 ==
Display images horizontally.  Add:
按水平方向显示图片。添加:
     .one-image {
     .one-image {
           display: inline;
           display: inline;
     }
     }
to the css of the theme you are using.
到正在使用的外观主题的css。


----
----
Display a 4x4 grid of recent images, images set to a max size of 50, in a template:
在模板中以4x4格显示最近访问的图片,图片最大尺寸设定为50:
   {literal}
   {literal}
   <style>
   <style>
第118行: 第118行:
</pre>
</pre>


Adjust the .g2imageblock css width if you are using a larger maxSize.
如果你使用更大的maxSize的话,就对.g2imageblock css的宽度进行调整。


----
----
==Permissions, Authorizations, and Passwort-Protected Items==
==权限,授权以及密码加密的项目==
The image block module checks permissions first. This means that a user can only see albums or images in the image block for which he/she has sufficient authorization. If an album is password-protected using the [[Gallery:Modules:password|password]] module, items inside the album will not be shown in the image block (unless the user is the owner of the album). However, the ablum itself will be shown in the image block. Images or other items that are password-protected directly will also be shown in the image block with their thumbnails. If the user nagivates to one of these password-protected albums or items, he/she will be asked for a password.
图片区块(image block)模块首先检查权限。这意味着用户拥有足够的权限才能浏览图片区块中的相册和图片。如果某相册使用[[Gallery:Modules:password|password]]模块进行了密码加密的话,相册内部的项目就不会显示在图片区块中(相册拥有者除外)。但相册本身还是会被显示在图片区块之中。直接受密码加密保护的图片或其它项目也会在图片区块中以缩略图的形式显示出来。如果用户浏览这些受密码保护的相册或项目之一时,就会被要求输入密码。
To exclude password-protected albums and items from the image block completely, the following coding needs to be added to the file gallery2/modules/imageblock/classes/ImageBlockHelper.class before this statement.
为了从图片区块中将密码保护的相册或项目完全排除,以下代码要加载文件gallery2/modules/imageblock/classes/ImageBlockHelper.class中此行语句之前。
  list ($ret, $owner) = GalleryCoreApi::loadEntitiesById($item->getOwnerId());
  list ($ret, $owner) = GalleryCoreApi::loadEntitiesById($item->getOwnerId());


Coding to be added:
要添加的代码:
  //check if the item is directly protected by a password.
  //检查项目是否直接受密码保护。
  //in this case, do not show it in the image block, not even as a preview:
  //如果是这样的话,不要将其显示在图片区块中,预览也不行:
  if( $item->hasOnLoadHandler('Password') ){
  if( $item->hasOnLoadHandler('Password') ){
   continue;
   continue;
  }
  }


==Requested Features==
==被请求的特点==
Currently there are no feature requests for this module.
目前尚无有关此模块的特点请求。


==Bugs==
==Bugs==
Currently there are no known issues for this module.
目前尚无有关此模块的已知问题。


[[Category:Gallery 2:Modules]]
[[Category:Gallery 2:Modules]]

2008年8月19日 (二) 09:52的最新版本

Image Block模块[ ]

使得区块可用做外观主题显示随机/最近/访问量最高的图片或相册。

描述[ ]

显示随机的图片或访问量最高的图片的突出,或从一堆其他图片区块类型中进行选择来在某特定相册或所有Gallery页面上显示。或者使用外部图片区块来在其他网站上显示这些图片。

特点[ ]

  • 选择不同类型的图片区块(image block):随机图片,最近访问的图片,访问量最高的图片,随机相册高亮,最近访问的相册高亮,访问量最高的相册,每日图片(每日改变一次),每周图片(每周改变一次),每月图片(每月改变一次),每日相册高亮,每周相册高亮以及每月相册高亮
  • 添加多个图片区块
  • 为每个图片区块设置是否显示标题,日期,访问计数器
  • 另外,如果在外观主题模板(theme.tpl,album.tpl,photo.tpl)中手动添加了区块或者你使用外部图片区块的话,就可以选择显示某个itemID所定义的特定项目
  • 使用外部图片区块(external imageblock)在其他网站或你网站的其他页面上显示Gallery(随机)图片
  • 限制给定id相册下Gallery子树的项目选择(仅对模板中或外部图片区块中手动添加的图片区块可用)
  • 为区块选择一个最大显示尺寸
  • 显示全尺寸的图片

用法[ ]

  • 如果需要的话在下载页面中下载此模块。G2的最小安装包及典型安装包中没有包括进此模块。
  • 站点管理(site admin) -> 模块(modules)中安装并激活此模块。
  • 站点管理(site admin) -> 图片区块(Image Blocks)中进行配置
  • 站点管理(site admin) -> 外观主题(themes) -> matrix(或其他某个激活或被使用的外观主题)的边栏中添加图片区块(Add image blocks)
  • 你可以单独地对每个图片区块进行配置:参见如何安装图片区块(Image Blocks)
  • 现在你以及站点访问者就可以在所有相册或相片页面的边栏中看到图片区块(image blocks)了。

另见:

外部选项[ ]

以下选项可用:

blocks       竖直分隔线(|)分隔列表:
               randomImage, recentImage, viewedImage, randomAlbum, recentAlbum,
               viewedAlbum, dailyImage, weeklyImage, monthlyImage, dailyAlbum,
               weeklyAlbum, monthlyAlbum, specificItem; default is randomImage
show         竖直分隔线(|)分隔列表:
               title, date, views, owner, heading, fullSize, rawImage, none
itemId       限制给定id相册下Gallery子树的项目选择;
               或当使用specificItem区块类型时,对要显示的项目id进行限制
maxSize      将图片按比例扩大到最大尺寸。如果单独使用的话,Gallery将会定位尺寸设定最接近的
               图片为定义数值 – 更大的图片则会在你的浏览器中根据需要按比例缩小。
               如果与g2_show=fullSize一起定义的话,那么全尺寸的图片将总是被使用并根据需要按比例缩小。
exactSize    除了不会替换小于所选尺寸的图片之外,它跟g2_maxSize几乎是一样的,
               因此你会获取最接近某特定尺寸的图片。注意如果更大的图片要在浏览器中按比例缩小的话,
               将会占用很多带宽。
link         Href为图片上的链接;无数值即为无链接;默认为链接到Gallery中的项目
linkTarget   添加一个链接目标(例如在新的浏览器窗口中打开链接)


有必要对maxSize和exactSize参量做一个阐述:

  • maxSize – 为外部图片区块定义maxSize参量试图智能化地确定尺寸最为合适的图片以填充区块。此特点的加入将帮助用户及管理者有效地降低带宽消耗,并返回与所请求尺寸相近的图片。之前(而目前已此方式定义时),maxSize的唯一用处就是与fullSize视图选项一起使用。返回了庞大尺寸的图片,但按maxSize所定义的尺寸被浏览器缩小了。现在maxSize参量可以单独使用了,无需再跟fullSize视图选项一起使用。
示例图片:
    100px 缩略图
    500px 重设尺寸的图片
    1024px 原始尺寸的图片

maxSize参量:
    maxSize=299 返回100px的缩略图,因为这是与
       所请求的maxSize"最接近"的尺寸。(约199px,然而
       500px的图片约为201px)

    maxSize=300 返回500px的重设尺寸图片,因为在这种情况下,
       一个图片具有两种尺寸,而这两种尺寸都同等接近时
       (都约为200px),那么其中稍大的尺寸将应质量需要被选中并返回

    maxSize=800 返回1024px的原始尺寸图片
  • exactSize – 正如maxSize,但除此之外返回的图片会被保证由下一较大尺寸进行向下采样。这意味着你永远不会得到比所定义尺寸稍小的图片,不过定义的尺寸大于原始尺寸图片的情况除外。
示例图片:
    100px 缩略图
    500px 重设尺寸的图片
    1024px 原始尺寸的图片

exactSize参量:
    exactSize=299 返回500px的重设尺寸图片,因为这是
       最接近的稍大尺寸图片。

    exactSize=500 返回500px 的重设尺寸图片,因为这是
       最符合的。

    exactSize=800 (或更大)返回1024px的原始尺寸图片


注:在此模块最新版之前的版本中,"exactSize"参量是不存在的而"maxSize"参量的功能不是如上所述。

我并不确定,但我认为以上的资料适用于1.0.11版(与Gallery 2.2 RC1兼容)而不适用于Gallery2.1.2所带模块的版本。

举例[ ]

按水平方向显示图片。添加:

    .one-image {
         display: inline;
    }

到正在使用的外观主题的css。


在模板中以4x4格显示最近访问的图片,图片最大尺寸设定为50:

  {literal}
  <style>
  .one-image {
     display: inline;
  }
  .g2imageblock {
     width: 106px;
  }
  </style>
  {/literal}
   <div class="g2imageblock">
   {g->block type="imageblock.ImageBlock" blocks="recentImage|recentImage|recentImage|recentImage" maxSize=50}
   </div>

如果你使用更大的maxSize的话,就对.g2imageblock css的宽度进行调整。


权限,授权以及密码加密的项目[ ]

图片区块(image block)模块首先检查权限。这意味着用户拥有足够的权限才能浏览图片区块中的相册和图片。如果某相册使用password模块进行了密码加密的话,相册内部的项目就不会显示在图片区块中(相册拥有者除外)。但相册本身还是会被显示在图片区块之中。直接受密码加密保护的图片或其它项目也会在图片区块中以缩略图的形式显示出来。如果用户浏览这些受密码保护的相册或项目之一时,就会被要求输入密码。 为了从图片区块中将密码保护的相册或项目完全排除,以下代码要加载文件gallery2/modules/imageblock/classes/ImageBlockHelper.class中此行语句之前。

list ($ret, $owner) = GalleryCoreApi::loadEntitiesById($item->getOwnerId());

要添加的代码:

//检查项目是否直接受密码保护。
//如果是这样的话,不要将其显示在图片区块中,预览也不行:
if( $item->hasOnLoadHandler('Password') ){
  continue;
}

被请求的特点[ ]

目前尚无有关此模块的特点请求。

Bugs[ ]

目前尚无有关此模块的已知问题。