Skip to content

Commit 10c11ff

Browse files
committed
simplify public_id / folder split
1 parent 562affe commit 10c11ff

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,15 +398,16 @@ public function prepare_upload( $post, $down_sync = false ) {
398398
$public_id = $cld_folder . $file_info['filename'];
399399
}
400400

401+
// Assume that the public_id is a root item.
402+
$public_id_folder = '';
403+
$public_id_file = $public_id;
404+
405+
// Check if in a lower level.
401406
if ( false !== strpos( $public_id, '/' ) ) {
402407
// Split the public_id into path and filename to allow filtering just the ID and not giving access to the path.
403408
$public_id_info = pathinfo( $public_id );
404409
$public_id_folder = trailingslashit( $public_id_info['dirname'] );
405410
$public_id_file = $public_id_info['filename'];
406-
} else {
407-
// File is in the root of cloudinary.
408-
$public_id_folder = '';
409-
$public_id_file = $public_id;
410411
}
411412

412413
// Prepare upload options.

0 commit comments

Comments
 (0)