diff --git a/php/class-delivery.php b/php/class-delivery.php index b69b438c3..a47cfb018 100644 --- a/php/class-delivery.php +++ b/php/class-delivery.php @@ -184,7 +184,7 @@ public function process_featured_image( $html, $post_id, $attachment_id ) { $tag_element['atts']['class'][] = 'wp-image-' . $attachment_id; $tag_element['atts']['class'][] = 'wp-post-' . $post_id; - if ( true === (bool) $this->media->get_post_meta( $post_id, Global_Transformations::META_FEATURED_IMAGE_KEY, true ) ) { + if ( true === (bool) get_post_meta( $post_id, Global_Transformations::META_FEATURED_IMAGE_KEY, true ) ) { $tag_element['atts']['class'][] = 'cld-overwrite'; } diff --git a/php/class-media.php b/php/class-media.php index 4fa67ad65..58c9a1b6f 100644 --- a/php/class-media.php +++ b/php/class-media.php @@ -1508,6 +1508,12 @@ private function create_attachment( $asset, $public_id ) { $this->update_post_meta( $attachment_id, Sync::META_KEYS['transformation'], $asset['transformations'] ); } + // Create a trackable key in post meta to allow getting the attachment id from URL with transformations. + update_post_meta( $attachment_id, '_' . md5( $sync_key ), true ); + + // Create a trackable key in post meta to allow getting the attachment id from URL. + update_post_meta( $attachment_id, '_' . md5( 'base_' . $public_id ), true ); + // capture the delivery type. $this->update_post_meta( $attachment_id, Sync::META_KEYS['delivery'], $asset['type'] ); // Capture the ALT Text. @@ -2101,7 +2107,7 @@ public function get_upload_options( $attachment_id ) { public function maybe_overwrite_featured_image( $attachment_id ) { $overwrite = false; if ( $this->doing_featured_image && $this->doing_featured_image === (int) $attachment_id ) { - $overwrite = (bool) $this->get_post_meta( get_the_ID(), Global_Transformations::META_FEATURED_IMAGE_KEY, true ); + $overwrite = (bool) get_post_meta( get_the_ID(), Global_Transformations::META_FEATURED_IMAGE_KEY, true ); } return $overwrite; diff --git a/php/media/class-upgrade.php b/php/media/class-upgrade.php index e70ea727f..f406225d4 100644 --- a/php/media/class-upgrade.php +++ b/php/media/class-upgrade.php @@ -142,8 +142,8 @@ public function convert_cloudinary_version( $attachment_id ) { if ( ! empty( $transformations ) ) { $sync_key .= wp_json_encode( $transformations ); } - delete_post_meta( $attachment_id, '_' . md5( $sync_key ), true ); - delete_post_meta( $attachment_id, '_' . md5( 'base_' . $public_id ), true ); + update_post_meta( $attachment_id, '_' . md5( $sync_key ), true ); + update_post_meta( $attachment_id, '_' . md5( 'base_' . $public_id ), true ); // Get a new uncached signature. $this->sync->get_signature( $attachment_id, true ); diff --git a/php/sync/class-upload-sync.php b/php/sync/class-upload-sync.php index d9362db4d..d8683bcf8 100644 --- a/php/sync/class-upload-sync.php +++ b/php/sync/class-upload-sync.php @@ -282,6 +282,13 @@ function ( $is_synced, $post_id ) use ( $attachment_id ) { $this->media->update_post_meta( $attachment_id, Sync::META_KEYS['version'], $result['version'] ); // Set the delivery type. $this->media->update_post_meta( $attachment_id, Sync::META_KEYS['delivery'], $result['type'] ); + + // Create a trackable key in post meta to allow getting the attachment id from URL with transformations. + update_post_meta( $attachment_id, '_' . md5( $options['public_id'] ), true ); + + // Create a trackable key in post meta to allow getting the attachment id from URL. + update_post_meta( $attachment_id, '_' . md5( 'base_' . $options['public_id'] ), true ); + // Update signature for all that use the same method. $this->sync->sync_signature_by_type( $attachment_id, $type ); // Update options and public_id as well (full sync).