Cache images
This commit is contained in:
parent
b15a15afbc
commit
a345db162a
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Aweos\Resizer\Classes;
|
||||
|
||||
use Cache;
|
||||
use Storage;
|
||||
use Aweos\Resizer\Models\Attachment;
|
||||
use Aweos\Resizer\Models\Setting;
|
||||
|
@ -22,7 +23,9 @@ class TagPresenter {
|
|||
}
|
||||
|
||||
public function cacheOutput() {
|
||||
return $this->output();
|
||||
return Cache::rememberForever('responsive-image-'.$this->attachment->id, function() {
|
||||
return $this->output();
|
||||
}).' '.$this->attrs;
|
||||
}
|
||||
|
||||
public function output() {
|
||||
|
@ -58,7 +61,7 @@ class TagPresenter {
|
|||
'sizes' => $sizes->implode(', '),
|
||||
'srcset' => $srcset->implode(', '),
|
||||
'alt' => $this->attachment->title
|
||||
])).' '.$this->attrs;
|
||||
]));
|
||||
}
|
||||
|
||||
private function htmlAttributes($attr) {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
use Model;
|
||||
use Storage;
|
||||
use Cache;
|
||||
|
||||
/**
|
||||
* Setting Model
|
||||
|
@ -65,4 +66,8 @@ class Attachment extends Model
|
|||
public function getUrlAttribute() {
|
||||
return Storage::disk('uploads')->url($this->source->path);
|
||||
}
|
||||
|
||||
public function beforeDelete() {
|
||||
Cache::forget('responsive-image-'.$this->id);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue