Cache background image

This commit is contained in:
Hillel Coren 2018-04-17 21:12:10 +03:00
parent a637a8312a
commit bdd218ed79
2 changed files with 18 additions and 1 deletions

View File

@ -234,6 +234,23 @@ class Document extends EntityModel
return $disk->get($this->path);
}
/**
* @return mixed
*/
public function getRawCached()
{
$key = 'image:' . $this->path;
if ($image = cache($key)) {
// do nothing
} else {
$image = $this->getRaw();
cache([$key => $image], 120);
}
return $image;
}
/**
* @return mixed
*/

View File

@ -89,7 +89,7 @@
@endif
@if ($account->isEnterprise() && $account->background_image_id && $account->background_image)
window.accountBackground = "{{ Form::image_data($account->background_image->getRaw(), true) }}";
window.accountBackground = "{{ Form::image_data($account->background_image->getRawCached(), true) }}";
@endif
var NINJA = NINJA || {};