diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/connect/class-api.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/connect/class-api.php index bd6166060..e44826427 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/connect/class-api.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/connect/class-api.php @@ -228,6 +228,7 @@ function ( $item ) use ( $transformation_index ) { * @param string|null $public_id The Public ID to get a url for. * @param array $args Additional args. * @param array $size The WP Size array. + * @param bool $clean Flag to produce a non variable size url. * * @return string */ @@ -398,10 +399,11 @@ public function upload_large( $attachment_id, $args ) { * @param int $attachment_id Attachment ID to upload. * @param array $args Array of upload options. * @param array $headers Additional headers to use in upload. + * @param bool $try_remote Flag to try_remote upload. * * @return array|\WP_Error */ - public function upload( $attachment_id, $args, $headers = array() ) { + public function upload( $attachment_id, $args, $headers = array(), $try_remote = true ) { $resource = ! empty( $args['resource_type'] ) ? $args['resource_type'] : 'image'; $resource = $this->convert_resource_type( $resource ); @@ -415,7 +417,7 @@ public function upload( $attachment_id, $args, $headers = array() ) { $disable_https_fetch = false; } // Check if we can try http file upload. - if ( empty( $headers ) && empty( $disable_https_fetch ) ) { + if ( empty( $headers ) && empty( $disable_https_fetch ) && true === $try_remote ) { $args['file'] = $file_url; } else { // We should have the file in args at this point, but if the transient was set, it will be defaulting here. diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-sync.php index fbacfc049..5c6b2ee47 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-sync.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-sync.php @@ -201,9 +201,10 @@ public function setup() { */ public function upload_asset( $attachment_id ) { - $type = $this->sync->get_sync_type( $attachment_id ); - $options = $this->media->get_upload_options( $attachment_id ); - $public_id = $options['public_id']; + $type = $this->sync->get_sync_type( $attachment_id ); + $options = $this->media->get_upload_options( $attachment_id ); + $public_id = $options['public_id']; + $try_remote = 'cloud_name' === $type ? false : true; // Add the suffix before uploading. if ( $this->media->get_public_id( $attachment_id ) === $public_id ) { @@ -215,7 +216,7 @@ public function upload_asset( $attachment_id ) { } // Run the upload Call. - $result = $this->connect->api->upload( $attachment_id, $options ); + $result = $this->connect->api->upload( $attachment_id, $options, array(), $try_remote ); if ( ! is_wp_error( $result ) ) {