diff --git a/php/class-media.php b/php/class-media.php index 22b6e2302..302b91fa0 100644 --- a/php/class-media.php +++ b/php/class-media.php @@ -190,6 +190,7 @@ public function get_syncable_delivery_types() { */ return apply_filters( 'cloudinary_syncable_delivery_types', $types ); } + /** * Get convertible extensions and converted file types. * @@ -273,9 +274,10 @@ public function is_media( $attachment_id ) { */ public function is_local_media( $attachment_id ) { $local_host = wp_parse_url( get_site_url(), PHP_URL_HOST ); - $media_host = wp_parse_url( get_the_guid( $attachment_id ), PHP_URL_HOST ); + $guid = get_the_guid( $attachment_id ); + $media_host = wp_parse_url( $guid, PHP_URL_HOST ); - return $local_host === $media_host; + return $local_host === $media_host || $this->is_cloudinary_url( $guid ); } /** @@ -1379,7 +1381,7 @@ public function is_cloudinary_url( $url ) { * @return bool */ public function is_cloudinary_sync_folder( $url ) { - $path = wp_parse_url( $url, PHP_URL_PATH ); + $path = wp_parse_url( $url, PHP_URL_PATH ); $parts = explode( '/', $path ); // Remove public id and file name. @@ -1714,18 +1716,15 @@ public function media_column_value( $column_name, $attachment_id ) { ?> is_local_media( $attachment_id ) ) : + elseif ( ! $this->is_local_media( $attachment_id ) ) : ?> get_media_delivery( $attachment_id ) ) : + elseif ( 'fetch' === $this->get_media_delivery( $attachment_id ) ) : ?> get_media_delivery( $attachment_id ) ) : + elseif ( 'sprite' === $this->get_media_delivery( $attachment_id ) ) : ?> array( 'generate' => function ( $attachment_id ) { - $meta = $this->managers['media']->get_post_meta( $attachment_id ); + $meta = $this->managers['media']->get_post_meta( $attachment_id ); $return = false; foreach ( $meta as $key => $value ) { if ( get_post_meta( $attachment_id, $key, true ) === $value ) { diff --git a/php/media/class-upgrade.php b/php/media/class-upgrade.php index 851b01bb1..910b8ad70 100644 --- a/php/media/class-upgrade.php +++ b/php/media/class-upgrade.php @@ -98,7 +98,7 @@ public function convert_cloudinary_version( $attachment_id ) { // Remove extension. $path = pathinfo( $public_id ); $public_id = str_replace( $path['basename'], $path['filename'], $public_id ); - $this->media->update_post_meta( $attachment_id, Sync::META_KEYS['public_id'], $public_id ); + update_post_meta( $attachment_id, Sync::META_KEYS['public_id'], $public_id ); $this->media->update_post_meta( $attachment_id, Sync::META_KEYS['version'], $asset_version ); if ( ! empty( $asset_transformations ) ) { $this->media->update_post_meta( $attachment_id, Sync::META_KEYS['transformation'], $asset_transformations );