Extended API allow you to do quickly :
- Generating thumbnail image on the fly.
- Example
- PHP : PstImage::cacheResize($path, $name, $height, $width, PstImage::METHOD_CROP);
- Smarty : {imageResize path=$path name=$name with=150}
- Example
- Adding new smarty function with the method smartyRegisterFunction
- Exemple : self::smartyRegisterFunction($this->context->smarty, 'function', 'imageResize', 'smartyImageResize');
- Easy installation of hooks thanks to a simple array
- Easy Installation tab in the navigation of backoffice
- Exemple : $this->installTab('PstTools','Super Tools',self::TAB_DEFAULT_ROOT)
- A function that forces the reload class.
- Overloading the autoloader to include self class modules.
class PstBlog extends PstModule
{
protected $_config = array(
'general' => array(
'label' => 'General',
'fields' => array(
'PST_PSTBLOG_GENERAL_BLOG_TITLE' => array(
'type' => 'text_lang',
'default_value' => '',
'label' => 'Blog title',
)
)
)
);
}
protected $_hook_list = array('displayFooter','displayHeader');
$this->createHook('CustomHook');
$this->installTab('AdminPstBlogConfig', "Super Blog", self::TAB_DEFAULT_ROOT);
$this->installMeta('Article detail', 'show-article', 'Show Articles', '', 'articledetail');
$this->createImgDirectory('pstblog/ArticleCategory/cover');
PstImage::cacheResize($path, $fileName, 60,60);
<img class="img-responsive" src="{imageResize name=$element->cover path=$element->cover_path width=500 height=500}" />
$this->setLifetime(self::LIFETIME_WEEK);
$smartyCacheId = $this->getCacheKey($tempalteName, $addictionalParams);
public function hookControllerConstruct(){
$this->checkControllerActive();
$this->registerImageResizeSmarty();
}
public function registerImageResizeSmarty(){
if(!function_exists('smartyImageResize'))
{
function smartyImageResize($params,&$smarty){
$path = @$params['path'];
$name = @$params['name'];
$height = @$params['height'];
$width = @$params['width'];
$customPath = @$params['customPath'];
$method = isset($params['method'])?$params['method']:PstImage::METHOD_RESIZE;
if($customPath)
{
return PstImage::cacheResizeCustomPath($path, $name,$height, $width,$method);
}
else
{
return PstImage::cacheResize($path, $name,$height, $width,$method);
}
}
self::smartyRegisterFunction($this->context->smarty, 'function', 'imageResize', 'smartyImageResize');
}
}