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