afxsoft/phpimagecache
Composer 安装命令:
composer require afxsoft/phpimagecache
包简介
Fork of https://github.com/nielse63/php-image-cache using psr-4 autoload and removing unused stuff.
README 文档
README
Image Cache is a very simple PHP class that accepts an image source and will compress and cache the file, move it to a new directory, and returns the new source for the image.
Installation
Install Composer by opening Terminal and navigating to the directory in which you'd like to install Image Cache.
Installation Execute this bash command from your project’s root directory:
composer require afxsoft/phpimagecache:dev-master
Basic Usage The class is pretty small, and very basic. First, include the file and initialize the class:
require_once 'ImageCache.php'; $imagecache = new Afxsoft\App\ImageCache();
Optional: Set the location of the directory to house your cached images:
$imagecache->cached_image_directory = dirname(__FILE__) . '/images/cached';
Next, reference the image that you want compressed and store the new image source in a variable. Echo this variable within the 'src' attribute of an image tag:
$cached_src = $imagecache->cache( 'images/unsplash1.jpeg' ); /// <!-- later in your HTML --> <img src="<?php echo $cached_src; ?>" alt="Amazingly awesome photo">
统计信息
- 总下载量: 34
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Creative
- 更新时间: 2018-08-29