@@ -72,7 +72,7 @@ private function register_hooks() {
7272 // Hook for on demand upload push.
7373 add_action ( 'shutdown ' , array ( $ this , 'init_background_upload ' ) );
7474 // Hook into auto upload sync.
75- add_filter ( 'cloudinary_on_demand_sync_enabled ' , array ( $ this , 'auto_sync_enabled ' ) );
75+ add_filter ( 'cloudinary_on_demand_sync_enabled ' , array ( $ this , 'auto_sync_enabled ' ), 10 , 2 );
7676 // Handle bulk and inline actions.
7777 add_filter ( 'handle_bulk_actions-upload ' , array ( $ this , 'handle_bulk_actions ' ), 10 , 3 );
7878 // Add inline action.
@@ -160,14 +160,20 @@ public function handle_bulk_actions( $location, $action, $post_ids ) {
160160 * Check if auto-sync is enabled.
161161 *
162162 * @param bool $enabled Flag to determine if autosync is enabled.
163+ * @param int $post_id The post id currently processing.
163164 *
164165 * @return bool
165166 */
166- public function auto_sync_enabled ( $ enabled ) {
167+ public function auto_sync_enabled ( $ enabled, $ post_id ) {
167168 if ( isset ( $ this ->plugin ->config ['settings ' ]['sync_media ' ]['auto_sync ' ] ) && 'on ' === $ this ->plugin ->config ['settings ' ]['sync_media ' ]['auto_sync ' ] ) {
168169 $ enabled = true ;
169170 }
170171
172+ // Check if it was synced before to allow re-sync for changes.
173+ if ( ! empty ( $ this ->plugin ->components ['sync ' ]->get_signature ( $ post_id ) ) ) {
174+ $ enabled = true ;
175+ }
176+
171177 return $ enabled ;
172178 }
173179
@@ -211,7 +217,7 @@ public function prep_on_demand_upload( $cloudinary_id, $attachment_id ) {
211217 $ attachment_id = intval ( $ attachment_id );
212218 if ( $ attachment_id && false === $ cloudinary_id ) {
213219 // Check that this has not already been prepared for upload.
214- if ( ! $ this ->is_pending ( $ attachment_id ) && apply_filters ( 'cloudinary_on_demand_sync_enabled ' , $ this ->enabled ) ) {
220+ if ( ! $ this ->is_pending ( $ attachment_id ) && apply_filters ( 'cloudinary_on_demand_sync_enabled ' , $ this ->enabled , $ attachment_id ) ) {
215221 $ max_size = ( wp_attachment_is_image ( $ attachment_id ) ? 'max_image_size ' : 'max_video_size ' );
216222 $ file = get_attached_file ( $ attachment_id );
217223 // Get the file size to make sure it can exist in cloudinary.
0 commit comments