Skip to content

Commit d1356fd

Browse files
jl-anlemoine
andauthored
feat: add filter to $output before it is cached (#2910)
Add `timber/output/pre-cache` filter to hook into cache output before it's cached. --------- Co-authored-by: Nicolas Lemoine <[email protected]>
1 parent 5d1470f commit d1356fd

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/ImageHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ public static function get_sideloaded_file_loc($file)
396396

397397
/**
398398
* Filters basename for sideloaded files.
399-
* @since 2.0.1
399+
* @since 2.1.0
400400
* @example
401401
* ```php
402402
* // Change the basename used for sideloaded images.

src/Loader.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,17 @@ public function render($file, $data = null, $expires = false, $cache_mode = self
176176

177177
$template = $twig->load($file);
178178
$output = $template->render($data);
179+
180+
/**
181+
* Filters $output before it is cached.
182+
*
183+
* @since 2.1.0
184+
*
185+
* @param string $output
186+
* @param array $data
187+
* @param string $file
188+
*/
189+
$output = \apply_filters('timber/output/pre-cache', $output, $data, $file);
179190
}
180191

181192
if (false !== $output && false !== $expires && null !== $key) {

0 commit comments

Comments
 (0)