Skip to content

Commit

Permalink
Added MediaTrait::clearMediaCache() to allow cache to be cleared
Browse files Browse the repository at this point in the history
  • Loading branch information
mahagr committed Jul 20, 2018
1 parent c8ab5d3 commit ba0a8c4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

1. [](#new)
* Added twig filters for casting values: `|string`, `|int`, `|bool`, `|float`, `|array`
1. [](#improved)
* Added `MediaTrait::clearMediaCache()` to allow cache to be cleared
1. [](#bugfix)
* Made `|markdown` filter HTML safe

Expand Down
12 changes: 12 additions & 0 deletions system/src/Grav/Common/Media/Traits/MediaTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ protected function setMedia(MediaCollectionInterface $media)
return $this;
}

/**
* Clear media cache.
*/
protected function clearMediaCache()
{
/** @var Cache $cache */
$cache = Grav::instance()['cache'];

$cacheKey = md5('media' . $this->getCacheKey());
$cache->delete($cacheKey);
}

/**
* @return string
*/
Expand Down

0 comments on commit ba0a8c4

Please sign in to comment.