Skip to content

Commit 6f7a3f9

Browse files
author
Marco Pereirinha
committed
Maybe get the public_id for fetch images
1 parent 08f6e73 commit 6f7a3f9

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

php/media/class-upgrade.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public function convert_cloudinary_version( $attachment_id ) {
6464
$asset_version = 1;
6565
$asset_transformations = array();
6666
$id_parts = array();
67+
$public_id = $this->get_fetch_public_id( $path, $attachment_id );
6768
foreach ( $parts as $val ) {
6869
if ( empty( $val ) ) {
6970
continue;
@@ -140,6 +141,25 @@ public function convert_cloudinary_version( $attachment_id ) {
140141
return $public_id;
141142
}
142143

144+
/**
145+
* Maybe the upgraded attachment is a fetch image.
146+
*
147+
* @param string $path The attachment path.
148+
* @param int $attachment_id The attachment ID.
149+
*
150+
* @return string
151+
*/
152+
public function get_fetch_public_id( $path, $attachment_id ) {
153+
$parts = explode( '/image/fetch/', $path );
154+
155+
if ( ! empty( $parts[1] ) ) {
156+
$this->media->update_post_meta( $attachment_id, Sync::META_KEYS['delivery'], 'fetch' );
157+
return $parts[1];
158+
}
159+
160+
return '';
161+
}
162+
143163
/**
144164
* Setup hooks for the filters.
145165
*/

0 commit comments

Comments
 (0)