Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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 );
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand All @@ -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 ) ) {

Expand Down