定制 makeitbetter/thumbnail 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

makeitbetter/thumbnail

Composer 安装命令:

composer require makeitbetter/thumbnail

包简介

PHP class for thumbnails creation

README 文档

README

Thumbnail - PHP class for thumbnails creation.

Demo: makeitbetter.su/projects/thumbnail

Public Variables

public static $sourceFolder Path to folder with images source.

public static $targetFolder Path to folder for thumbnails relative to the webroot.

public static $webRoot Path to web root. Default - $_SERVER['DOCUMENT_ROOT']

public static $paddingColor Hexadecimal RGB color to fill thumbnails padding. Default - ffffff.

public static $getThumbnailPathMethod Function that will create thumbnails path. Default - $this->_getThumbnailPath()

public $path Path to the image relative to the source folder.

public $stretch Whether to stretch the image whose size is less than the size of the thumbnail. Default - false

public $crop Whether to crop the image whose proportions do not match the proportions of the thumbnail. Default - false

public $width Thumbnails width. Default - 0 (Calculate using a source proportions)

public $height Thumbnails height. Default - 0 (Calculate using a source proportions)

Public methods

public static of($path, $width = 0, $height = 0, $crop = false, $stretch = false) Returns new object.

public width($width) Sets the thumbnails width. Height will be calculated using a source proportions. Returns its self.

public height($height) Sets the thumbnails height. Width will be calculated using a source proportions. Returns its self.

public size($width, $height) Sets the exact size of thumbnails. Returns its self.

public crop() Crops the image if its proportions do not match the proportions of the thumbnail. Returns its self.

public contain() Scales the image such it can fit inside thumbnails frame (with adding padding). Returns its self.

public stretch() Stretches small image to thumbnails size. Returns its self.

public nostretch() Leaves the size of small images as is (with adding padding). Returns its self.

public path() Creates a thumbnail if it absent. Returns a path to it. This method will be called when trying to convert an object to a string:

#!php
<img src="<?php echo Thumbnail::of('images/example.jpg', 100)->path();?>" />
<!-- equals : -->
<img src="<?php echo Thumbnail::of('images/example.jpg', 100);?>" />

public img($attributes = []) Wraps a path into a HTML-tag <img/>:

#!php
<img src="<?php echo Thumbnail::of('images/example.jpg', 100);?>" class="thumbnail" />
<!-- equals : -->
<?php echo Thumbnail::of('images/example.jpg', 100)->img(['class' => 'thumbnail']);?>

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2017-07-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固