@@ -141,7 +141,7 @@ class Api {
141141 * @param string The plugin version.
142142 */
143143 public function __construct ( $ connect , $ version ) {
144- $ this ->credentials = $ connect ->get_credentials ();
144+ $ this ->credentials = $ connect ->get_credentials ();
145145 $ this ->plugin_version = $ version ;
146146 // Use CNAME.
147147 if ( ! empty ( $ this ->credentials ['cname ' ] ) ) {
@@ -231,9 +231,9 @@ function ( $item ) use ( $transformation_index ) {
231231 * Generate a Cloudinary URL.
232232 *
233233 * @param string|null $public_id The Public ID to get a url for.
234- * @param array $args Additional args.
235- * @param array $size The WP Size array.
236- * @param bool $clean Flag to produce a non variable size url.
234+ * @param array $args Additional args.
235+ * @param array $size The WP Size array.
236+ * @param bool $clean Flag to produce a non variable size url.
237237 *
238238 * @return string
239239 */
@@ -408,10 +408,11 @@ public function upload_large( $attachment_id, $args ) {
408408 * @param int $attachment_id Attachment ID to upload.
409409 * @param array $args Array of upload options.
410410 * @param array $headers Additional headers to use in upload.
411+ * @param bool $try_remote Flag to try_remote upload.
411412 *
412413 * @return array|\WP_Error
413414 */
414- public function upload ( $ attachment_id , $ args , $ headers = array () ) {
415+ public function upload ( $ attachment_id , $ args , $ headers = array (), $ try_remote = true ) {
415416
416417 $ resource = ! empty ( $ args ['resource_type ' ] ) ? $ args ['resource_type ' ] : 'image ' ;
417418 $ resource = $ this ->convert_resource_type ( $ resource );
@@ -425,7 +426,7 @@ public function upload( $attachment_id, $args, $headers = array() ) {
425426 $ disable_https_fetch = false ;
426427 }
427428 // Check if we can try http file upload.
428- if ( empty ( $ headers ) && empty ( $ disable_https_fetch ) ) {
429+ if ( empty ( $ headers ) && empty ( $ disable_https_fetch ) && true === $ try_remote ) {
429430 $ args ['file ' ] = $ file_url ;
430431 } else {
431432 // We should have the file in args at this point, but if the transient was set, it will be defaulting here.
@@ -466,7 +467,7 @@ public function upload( $attachment_id, $args, $headers = array() ) {
466467 // Hook in flag to allow for non accessible URLS.
467468 if ( is_wp_error ( $ result ) ) {
468469 $ error = $ result ->get_error_message ();
469- $ code = $ result ->get_error_code ();
470+ $ code = $ result ->get_error_code ();
470471 /**
471472 * If there's an error and the file is a URL in the error message,
472473 * it's likely due to CURL or the location does not support URL file attachments.
0 commit comments