rufhausen/placeholder

Laravel 包,用于在应用程序中添加占位图像服务。

dev-master 2016-12-23 00:56 UTC

This package is not auto-updated.

Last update: 2024-09-28 20:14:40 UTC


README

Laravel 5.3 包,用于在应用程序中添加占位图像服务。

##支持的服务

目前支持 unsplash.itplaceimg.com

##入门指南

目前,该包包含两个外观:Placeholder 和 Placeimage。Placeholder 专门用于输出占位图像标签,而 Placeimage 将尝试使用现有的图像公共路径,如果图像不存在,则回退到占位图像。

##代码示例

####使用 Placeholder 标签

//Usage:

\Placeholder::make($width, $height = null, $tagAttributes = null, $imageOptions = null);

//Basic Example:

\Placeholder::make(200);
//outputs: <img src="https://unsplash.it/200/200?random"> using unsplash.it

//Full Example:

\Placeholder::make(200, 200, ['class' => 'img-responsive', 'id' => 'placeholder'], ['color' => 'grayscale']);
//outputs:
<img src="https://unsplash.it/g/200/200?random" class="img-responsive" id="placeholder"> using unsplash.it

####使用 Placeimage 标签

//Create an image tag that will revert to placeholder if the image does not exist:

//Usage:

\Placeimage::make($imagePath, $width, $height = null, $tagAttributes = null, $imageOptions = null);

//Basic Example:

\Placeimage::make('/img/test.jpg', 200);
//outputs: <img src="/img/test.jpg"> using unsplash.it
\Placeimage::make('/img/foo.jpg', 200, null, ['width' => '200', 'class' => 'img-responsive'], ['color' => 'grayscale']); //image does not exist

//outputs: <img src="https://unsplash.it/g/200/200?random" width="200" class="img-responsive"> using unsplash.it

##安装 将包添加到 composer.json

php composer.phar require intervention/image

将包提供者添加到 config/app.php 中的 providers 数组

Rufhausen\Placeholder\PlaceholderServiceProvider::class,

将外观添加到 config/app.php 中的 facades 数组

'Placeholder'  => Rufhausen\Placeholder\Placeholder::class,
'Placeimage'   => Rufhausen\Placeholder\PlaceImage::class,

发布配置

php artisan vendor:publish --provider="Rufhausen\Placeholder\PlaceholderServiceProvider"

许可证

Placeholder 在 MIT 许可证 下授权。

版权所有 2016 Gary Taylor