@@ -710,7 +710,7 @@ public function get_transformation( $transformations, $type ) {
710710 public function get_transformations ( $ attachment_id , $ transformations = array (), $ overwrite_transformations = false ) {
711711 static $ cache = array ();
712712
713- $ key = wp_json_encode ( func_get_args () );
713+ $ key = $ this -> get_cache_key ( func_get_args () );
714714 if ( isset ( $ cache [ $ key ] ) ) {
715715 return $ cache [ $ key ];
716716 }
@@ -861,10 +861,7 @@ public function attachment_url( $url, $attachment_id ) {
861861 public function apply_default_transformations ( array $ transformations , $ attachment_id ) {
862862 static $ cache = array (), $ freeform = array ();
863863
864- $ taxonomy_overwrite = $ this ->global_transformations ->is_taxonomy_overwrite ();
865- $ args = func_get_args ();
866- $ args [] = $ taxonomy_overwrite ;
867- $ key = wp_json_encode ( $ args );
864+ $ key = $ this ->get_cache_key ( func_get_args () );
868865 if ( isset ( $ cache [ $ key ] ) ) {
869866 return $ cache [ $ key ];
870867 }
@@ -980,6 +977,19 @@ public function default_image_freeform_transformations( $default ) {
980977 return $ default ;
981978 }
982979
980+ /**
981+ * Get a cache key for static caching.
982+ *
983+ * @param array $args The arguments array to generate a key with.
984+ *
985+ * @return string
986+ */
987+ protected function get_cache_key ( $ args ) {
988+ $ args [] = $ this ->global_transformations ->get_current_post ();
989+
990+ return md5 ( wp_json_encode ( $ args ) );
991+ }
992+
983993 /**
984994 * Generate a Cloudinary URL based on attachment ID and required size.
985995 *
@@ -1000,7 +1010,7 @@ public function cloudinary_url( $attachment_id, $size = array(), $transformation
10001010 return null ;
10011011 }
10021012 }
1003- $ key = wp_json_encode ( func_get_args () );
1013+ $ key = $ this -> get_cache_key ( func_get_args () );
10041014 if ( isset ( $ cache [ $ key ] ) ) {
10051015 return $ cache [ $ key ];
10061016 }
0 commit comments