diff --git a/wp-pwa.php b/wp-pwa.php index 5bbeb96..3aff9ee 100644 --- a/wp-pwa.php +++ b/wp-pwa.php @@ -273,7 +273,7 @@ function get_attachment_id( $url ) { } } - set_transient( $transient_name, $attachment_id, DAY_IN_SECONDS ); + set_transient( $transient_name, $attachment_id, 0 ); // never expires $this->update_image_id_transient_keys( $transient_name ); } @@ -333,9 +333,9 @@ function add_image_ids($data, $post_type, $request) { $result = $this->get_attachment_id($image->src); $id = $result['id']; $miss = $result['miss']; + $image->setAttribute('data-attachment-id-source', 'wp-query-transient-' . ($miss ? 'miss' : 'hit')); if ($id !== 0) { $image->setAttribute('data-attachment-id', $id); - $image->setAttribute('data-attachment-id-source', 'wp-query-transient-' . ($miss ? 'miss' : 'hit')); $imgIds[] = intval($id); } } @@ -357,9 +357,9 @@ function add_image_ids($data, $post_type, $request) { 'embeddable' => true, ) )); - $html = $dom->save(); - if ($html) $data->data['content']['rendered'] = $html; } + $html = $dom->save(); + if ($html) $data->data['content']['rendered'] = $html; $data->data['content_media'] = $imgIds; return $data; }