File tree Expand file tree Collapse file tree 2 files changed +28
-3
lines changed
cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -1678,12 +1678,22 @@ public function get_context_options( $attachment_id ) {
16781678 */
16791679 public function is_folder_synced ( $ attachment_id ) {
16801680
1681- $ return = true ; // By default all assets in WordPress will be synced.
1681+ $ is_folder_synced = true ; // By default all assets in WordPress will be synced.
16821682 if ( $ this ->sync ->been_synced ( $ attachment_id ) ) {
1683- $ return = ! empty ( $ this ->get_post_meta ( $ attachment_id , Sync::META_KEYS ['folder_sync ' ], true ) );
1683+ $ is_folder_synced = ! empty ( $ this ->get_post_meta ( $ attachment_id , Sync::META_KEYS ['folder_sync ' ], true ) );
16841684 }
16851685
1686- return $ return ;
1686+ /**
1687+ * Filter is folder synced flag.
1688+ *
1689+ * @param bool $is_folder_synced Flag value for is folder sync.
1690+ * @param int $attachment_id The attachment ID.
1691+ *
1692+ * @return bool
1693+ */
1694+ $ is_folder_synced = apply_filters ( 'cloudinary_is_folder_synced ' , $ is_folder_synced , $ attachment_id );
1695+
1696+ return (bool ) $ is_folder_synced ;
16871697 }
16881698
16891699 /**
Original file line number Diff line number Diff line change @@ -201,6 +201,21 @@ public function setup() {
201201 */
202202 public function upload_asset ( $ attachment_id ) {
203203
204+ add_filter ( 'cloudinary_doing_upload ' , '__return_true ' );
205+
206+ add_filter (
207+ 'cloudinary_is_folder_synced ' ,
208+ function ( $ is_synced , $ post_id ) use ( $ attachment_id ) {
209+ if ( $ post_id === $ attachment_id ) {
210+ return true ;
211+ }
212+
213+ return $ is_synced ;
214+ },
215+ 10 ,
216+ 2
217+ );
218+
204219 $ type = $ this ->sync ->get_sync_type ( $ attachment_id );
205220 $ options = $ this ->media ->get_upload_options ( $ attachment_id );
206221 $ public_id = $ options ['public_id ' ];
You can’t perform that action at this time.
0 commit comments