summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/_inc/lib/class.media-summary.php')
-rw-r--r--plugins/jetpack/_inc/lib/class.media-summary.php10
1 files changed, 10 insertions, 0 deletions
diff --git a/plugins/jetpack/_inc/lib/class.media-summary.php b/plugins/jetpack/_inc/lib/class.media-summary.php
index 98844e15..d129f5e6 100644
--- a/plugins/jetpack/_inc/lib/class.media-summary.php
+++ b/plugins/jetpack/_inc/lib/class.media-summary.php
@@ -6,7 +6,10 @@
*/
class Jetpack_Media_Summary {
+ private static $cache = array();
+
static function get( $post_id, $blog_id = 0, $args = array() ) {
+
$defaults = array(
'max_words' => 16,
'max_chars' => 256,
@@ -21,6 +24,11 @@ class Jetpack_Media_Summary {
$blog_id = get_current_blog_id();
}
+ $cache_key = "{$blog_id}_{$post_id}_{$args['max_words']}_{$args['max_chars']}";
+ if ( isset( self::$cache[ $cache_key ] ) ) {
+ return self::$cache[ $cache_key ];
+ }
+
if ( ! class_exists( 'Jetpack_Media_Meta_Extractor' ) ) {
jetpack_require_lib( 'class.media-extractor' );
}
@@ -242,6 +250,8 @@ class Jetpack_Media_Summary {
*/
$return = apply_filters( 'jetpack_media_summary_output', $return, $post_id );
+ self::$cache[ $cache_key ] = $return;
+
return $return;
}