2017 © Pedro Peláez
 

library laravel-static-image-cache

store/cache external images as a static file

image

campaigningbureau/laravel-static-image-cache

store/cache external images as a static file

  • Thursday, March 29, 2018
  • by campaigningbureau
  • Repository
  • 3 Watchers
  • 0 Stars
  • 157 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 9 Versions
  • 21 % Grown

The README.md

laravel-static-image-cache

store/cache external images as a static file, (*1)

Replaces URIs by a proxy route., (*2)

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

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

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, (*5)

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

Usage

This Package provides two helper functions: static_image and statify_text, (*6)

static_image

The static_image-helper can be used to generate the static file url for a given image url., (*7)

<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., (*8)

Usage:, (*9)

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

Clear the files

To clear all cached files manually you can use an artisan task., (*10)

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), (*11)

  • 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., (*12)

  • statify_domains: Holds an array of all domains that will be statified when calling the statify_text function., (*13)

Upgrade guide

From v1.x to v2.0

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

The Versions

29/03 2018

dev-master

9999999-dev

store/cache external images as a static file

  Sources   Download

MIT

The Requires

 

by Michael Scharl
by Stefan Schindler

29/03 2018

v2.1.2

2.1.2.0

store/cache external images as a static file

  Sources   Download

MIT

The Requires

 

by Michael Scharl
by Stefan Schindler

28/03 2018

v2.1.1

2.1.1.0

store/cache external images as a static file

  Sources   Download

MIT

The Requires

 

by Michael Scharl
by Stefan Schindler

28/03 2018

v2.1

2.1.0.0

store/cache external images as a static file

  Sources   Download

MIT

The Requires

 

by Michael Scharl
by Stefan Schindler

28/03 2018

v2.0

2.0.0.0

store/cache external images as a static file

  Sources   Download

MIT

The Requires

 

by Michael Scharl
by Stefan Schindler

25/10 2017
31/08 2017
07/04 2017

v1.0

1.0.0.0

store/cache external images as a static file

  Sources   Download

MIT

The Requires

 

by Michael Scharl