Offer option to disable default 'original' template
eightyfive opened this issue · comments
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:
- Ability to disable
original
template entirely - 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...
@eightyfive do you know if there's anything new?
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);
}
}
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.
@eightyfive thank you for answering.
I think I'll use middleware to avoid generating so many images.
Thank you again!