teddy/imgtodataurl
最新稳定版本:v1.1.1
Composer 安装命令:
composer require teddy/imgtodataurl
包简介
Converts images in CSS to DataUrl
README 文档
README
Converts images in CSS to DataUrl
Usage
$file = new \SplFileInfo(__DIR__ . '/css/test.css'); $imgToDataUrl = new Teddy\ImgToDataUrl(); $imgToDataUrl->setCssFromFile($file); $imgToDataUrl->setMaxSize(10); // convert only images with size <= 10 KB; (default = 3) echo $imgToDataUrl->convert();
Default public directory is set to $_SERVER['DOCUMENT_ROOT']
You may specify your own with new Teddy\ImgToDataUrl($file, __DIR__ . '/www');
There are two ways to pass CSS to ImgToDataUrl
Either you pass \splFileInfo with setCssFromFile($file) or a string with setCss($css).
The first one is better because it keeps information about relative paths
For example with structure
www/css/style.css
www/css/images/01.png
and
div {background-image: url(./images/01.png)}
The first one will look into correct path www/css/images/01.png but the second to www/images/01.png
统计信息
- 总下载量: 21
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-04-21