File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed
cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -357,6 +357,7 @@ public function prepare_upload( $post, $down_sync = false ) {
357357 // First check if this has a file and it can be uploaded.
358358 $ file = get_attached_file ( $ post ->ID );
359359 $ file_size = 0 ;
360+ $ downsync = false ;
360361 if ( empty ( $ file ) ) {
361362 return new \WP_Error ( 'attachment_no_file ' , __ ( 'Attachment did not have a file. ' , 'cloudinary ' ) );
362363 } elseif ( ! file_exists ( $ file ) ) {
@@ -373,6 +374,7 @@ public function prepare_upload( $post, $down_sync = false ) {
373374 }
374375 $ file = get_attached_file ( $ post ->ID );
375376 $ file_size = filesize ( $ file );
377+ $ downsync = true ;
376378 }
377379 }
378380 } else {
@@ -414,7 +416,7 @@ public function prepare_upload( $post, $down_sync = false ) {
414416 }
415417 // Check if this asset is a folder sync.
416418 $ folder_sync = $ media ->get_post_meta ( $ post ->ID , Sync::META_KEYS ['folder_sync ' ], true );
417- if ( ! empty ( $ folder_sync ) ) {
419+ if ( ! empty ( $ folder_sync ) && false === $ downsync ) {
418420 $ public_id_folder = $ cld_folder ; // Ensure the public ID folder is constant.
419421 } else {
420422 // Not folder synced, so set the folder to the folder that the asset originally came from.
You can’t perform that action at this time.
0 commit comments