Intervention / imagecache

Caching extension for the Intervention Image Class

Home Page:https://image.intervention.io/v2/usage/cache

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Offer option to disable default 'original' template

eightyfive opened this issue · comments

commented

Hi,

That would be great if we had the option to disable the original template. Indeed sometimes we don't want to make public our original images (which would come without 'watermark' and in best resolution).

A config would be neat. Actually I see 2 configs to be added:

  1. Ability to disable original template entirely
  2. Ability to specify the name of the default template (something other than original)

Those 2 configs could be merged into one:

  • 'original_template' => 'full'
  • 'original_template' => false // Would disable original template entirely

PS: Meanwhile I wrote my own ServiceProvider for Intervention (extending original one), but had to copy over most of the methods cause they are private, and so they cannot be inherited...

commented

@eightyfive do you know if there's anything new?

commented

Hi @padre, unfortunately nothing that I heard of.

I ended up changing my strategy and block original images via an HTTP middleware:

<?php
class BlockOriginalImage
{
    public function handle($request, Closure $next)
    {
        // Ex: images/original/
        $prefix = implode('/', [
            config('imagecache.route'),
            'original',
            ''
        ]);

        $isOriginal = strpos($request->path(), $prefix) === 0;

        if ($isOriginal) {
            return abort(404);
        }

        return $next($request);
    }
}
commented

I just realised I actually changed again strategy and I am now generating all different image sizes on "image created" event.

I save all templates in public/images/*:

  • public/images/md/name-of-image-1234567890.jpg
  • public/images/sm/name-of-image-1234567890.jpg
  • public/images/xl/name-of-image-1234567890.jpg
  • etc

That way I can cache static files more efficiently with Cloudflare or the like.

Note: In both cases I do not use the imagecache package anymore, only the image one.

commented

@eightyfive thank you for answering.

I think I'll use middleware to avoid generating so many images.

Thank you again!