定制 campaigningbureau/laravel-static-image-cache 二次开发

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

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

campaigningbureau/laravel-static-image-cache

Composer 安装命令:

composer require campaigningbureau/laravel-static-image-cache

包简介

store/cache external images as a static file

README 文档

README

store/cache external images as a static file

Replaces URIs by a proxy route.

When this proxy route is called, the original image is cached inside the configured directory and returned.

If the requested file was already cached, it is instead directly returned by the webserver.

Installation

composer require campaigningbureau/laravel-static-image-cache

Supported versions

Package version Required Laravel version Minimum PHP version
v10.1 10.x or 11.x 8.1
v8.0 8 7.3.0
v7.0 7 7.2.5
v5.0 6.0 7.2
v4.0 5.8 7.1.3
v3.0 5.6 7.1.3
v2.0 < 5.6 7.0

Setup

Add the service provider to the app.php provider array

/*
 * Package Service Providers...
 */
CampaigningBureau\LaravelStaticImageCache\Provider\LaravelStaticImageCacheProvider::class,

Usage

This Package provides two helper functions: static_image and statify_text

static_image

The static_image-helper can be used to generate the static file url for a given image url.

<img src="{{ static_image('https://images.domain.com/my-image.jpg') }}" alt="An external image">

statify_text

This helper function automatically statifies images from all domains that are configured in the statify_domains config entry inside the given string.

Usage:

if (function_exists('statify_text')) {
    $text = statify_text($text);
}

Clear the files

To clear all cached files manually you can use an artisan task.

php artisan static-image-cache:clear

Configuration

  • enabled: defines, if proxying and storing of the images is activated. Can be set to true, false or debug (If debug the package will synchronise the flag with the app.debug config value)

  • cache_path_prefix: The path prefix relative to public_path. This is where the images will be stored. This path will also be used as the proxy-url prefix.

  • statify_domains: Holds an array of all domains that will be statified when calling the statify_text function.

Upgrade guide

From v1.x to v2.0

all usages of staticImage() need to be replaced by the new static_image() function.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-02-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固