flame/thumbnail-helper

Nette 模板助手,用于懒加载创建缩略图

v3.0 2013-08-26 08:51 UTC

This package is not auto-updated.

Last update: 2024-09-23 13:18:20 UTC


README

Nette 模板助手,用于懒加载创建缩略图

### 安装 示例基于 Nette 版本 2.0.12,但该包也兼容 @dev 版本

## 在 bootstrap.php 中注册 "thumb" 扩展

\Flame\Thumb\DI\ThumbExtension::register($configurator);

### 注册 "thumb" 助手

	/**
     * Base presenter for all application presenters.
     */
    abstract class BasePresenter extends Presenter
    {

    	/**
    	 * @param null $class
    	 * @return \Nette\Templating\ITemplate
    	 */
    	protected function createTemplate($class = null)
    	{
    		$template = parent::createTemplate($class);
    		/** @var \Flame\Thumb\IRegister $thumb */
            $thumb = $this->context->getByType('Flame\Thumb\IRegister');
            $thumb->register($template);
    		return $template;
    	}
    }

### 设置变量(可选)在 config.neon

	thumb:
		paths:
			base: %wwwDir%
			thumbs: /media/thumbs

这就完成了!享受它吧!