Gallery:模块:imageblock

来自站长百科
Firebrance讨论 | 贡献2008年8月18日 (一) 17:21的版本
跳转至: 导航、​ 搜索

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 - 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.
示例图片:
    100px 缩略图
    500px 重设尺寸的图片
    1024px 原始尺寸的图片

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

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

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


NOTE: Until very recent versions of this module, the "exactSize" parameter did not exist and the "maxSize" parameter did not function as described above.

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.

举例

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

    .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的宽度进行调整。


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

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 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. 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.

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') ){
  continue;
}

被请求的特点

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

Bugs

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