noam148/yii2-image-resize 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

noam148/yii2-image-resize

最新稳定版本:1.1.0

Composer 安装命令:

composer require noam148/yii2-image-resize

包简介

A Yii2 component for resizing images (on the fly)

README 文档

README

A Yii2 component for resizing images and store it in a cache folder

Installation

The preferred way to install this extension is through composer.

  • Either run
php composer.phar require "noam148/yii2-image-resize" "*"

or add

"noam148/yii2-image-resize" : "*"

to the require section of your application's composer.json file.

  • Add a new component in components section of your application's configuration file, for example:
'components' => [
    'imageresize' => [
		'class' => 'noam148\imageresize\ImageResize',
		//path relative web folder. In case of multiple environments (frontend, backend) add more paths 
		'cachePath' =>  ['assets/images', '../../frontend/web/assets/images'],
		//use filename (seo friendly) for resized images else use a hash
		'useFilename' => true,
		//show full url (for example in case of a API)
		'absoluteUrl' => false,
	],
],

Usage

If you want to get a image url:

/*
 * $sImageFilePath_id: (required) path to file
 * $width/$height: (required) width height of the image
 * $mode: "outbound", "inset" or "{horz}:{vert}" where {horz} is one from "left", "cetrer", "right" and {vert} is one from "top", "center", "bottom"
 * $$quality: (1 - 100)
 * $chosenFileName: if config -> components -> imageresize -> useFilename is true? its an option to give a custom name else use original file name
 */
\Yii::$app->imageresize->getUrl($sImageFilePath, $width, $height, $mode, $quality, $chosenFileName);

If you got questions, tips or feedback? Please, let me know!

统计信息

  • 总下载量: 44.03k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 11
  • 点击次数: 1
  • 依赖项目数: 8
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 4
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2016-11-23