From 9c13747bf08f8a316310b6fb99e4f7d3cc62ce39 Mon Sep 17 00:00:00 2001 From: David Cramer Date: Mon, 8 Jun 2020 12:28:08 +0200 Subject: [PATCH 1/6] remove is_admin, and replace with is_downsize loop check. --- .../php/class-media.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-media.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-media.php index 56b38edf2..9cafaff37 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-media.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-media.php @@ -463,10 +463,10 @@ public function get_transformations_from_string( $str, $type = 'image' ) { * @return string Cloudinary URL. */ public function attachment_url( $url, $attachment_id ) { - if ( ! doing_action( 'wp_insert_post_data' ) && ! is_admin() ) { + if ( ! doing_action( 'wp_insert_post_data' ) && false === $this->in_downsize ) { $cloudinary_id = $this->cloudinary_id( $attachment_id ); if ( false !== $cloudinary_id ) { - $url = $this->cloudinary_url( $attachment_id, $cloudinary_id ); + $url = $this->cloudinary_url( $attachment_id ); } } From fd1274f6ff3fedce3028ee6c9554def0035e0d96 Mon Sep 17 00:00:00 2001 From: David Cramer Date: Mon, 8 Jun 2020 12:28:46 +0200 Subject: [PATCH 2/6] use image_downsize filter as correct short-circuit method --- .../php/class-media.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-media.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-media.php index 9cafaff37..6f6996e5d 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-media.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-media.php @@ -722,10 +722,17 @@ public function filter_downsize( $image, $attachment_id, $size ) { if ( false !== $cloudinary_id ) { $this->in_downsize = true; - $image = image_downsize( $attachment_id, $size ); + $intermediate = image_get_intermediate_size( $attachment_id, $size ); + if ( is_array( $intermediate ) ) { + // Found an intermediate size. + $image = array( + $this->convert_url( $intermediate['url'], $attachment_id, array(), false ), + $intermediate['width'], + $intermediate['height'], + true, + ); + } $this->in_downsize = false; - - $image[0] = $this->convert_url( $image[0], $attachment_id ); } return $image; From 250c5154a7d8da0dc494e87eb49d9bfa75434fa2 Mon Sep 17 00:00:00 2001 From: David Cramer Date: Mon, 8 Jun 2020 12:36:38 +0200 Subject: [PATCH 3/6] update regex to include - --- .../php/class-connect.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-connect.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-connect.php index 90b15c803..39bab567d 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-connect.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-connect.php @@ -157,7 +157,7 @@ public function verify_connection( $data ) { } // Pattern match to ensure validity of the provided url - if ( ! preg_match( '~^(?:CLOUDINARY_URL=)?cloudinary://[0-9]+:[A-Za-z_0-9]+@[A-Za-z]+~', $data['cloudinary_url'] ) ) { + if ( ! preg_match( '~^(?:CLOUDINARY_URL=)?cloudinary://[0-9]+:[A-Za-z_\-0-9]+@[A-Za-z]+~', $data['cloudinary_url'] ) ) { add_settings_error( 'cloudinary_connect', 'format_mismatch', From 4e6df9df41b3f880dfc1c5ef7aa248282ba7bbf7 Mon Sep 17 00:00:00 2001 From: David Cramer Date: Mon, 8 Jun 2020 13:11:23 +0200 Subject: [PATCH 4/6] allow for a re-sync, clear sync data and psuh --- .../php/sync/class-upload-sync.php | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-sync.php index 11377b172..cd9272c2d 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-sync.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-sync.php @@ -97,17 +97,16 @@ private function register_hooks() { * @return array */ function add_inline_action( $actions, $post ) { - if ( ! $this->plugin->components['sync']->is_synced( $post->ID ) ) { - if ( current_user_can( 'delete_post', $post->ID ) ) { - $action_url = add_query_arg( - array( - 'action' => 'cloudinary-push', - 'media[]' => $post->ID, - '_wpnonce' => wp_create_nonce( 'bulk-media' ), - ), - 'upload.php' - ); - + if ( current_user_can( 'delete_post', $post->ID ) ) { + $action_url = add_query_arg( + array( + 'action' => 'cloudinary-push', + 'media[]' => $post->ID, + '_wpnonce' => wp_create_nonce( 'bulk-media' ), + ), + 'upload.php' + ); + if ( ! $this->plugin->components['sync']->is_synced( $post->ID ) ) { $actions['cloudinary-push'] = sprintf( '%s', $action_url, @@ -115,6 +114,14 @@ function add_inline_action( $actions, $post ) { esc_attr( sprintf( __( 'Push to Cloudinary “%s”' ), 'asd' ) ), __( 'Push to Cloudinary', 'cloudinary' ) ); + } else { + $actions['cloudinary-push'] = sprintf( + '%s', + $action_url, + /* translators: %s: Attachment title. */ + esc_attr( sprintf( __( 'Push to Cloudinary “%s”' ), 'asd' ) ), + __( 'Re-sync to Cloudinary', 'cloudinary' ) + ); } } @@ -135,9 +142,12 @@ public function handle_bulk_actions( $location, $action, $post_ids ) { switch ( $action ) { case 'cloudinary-push' : foreach ( $post_ids as $post_id ) { - if ( ! $this->plugin->components['sync']->is_synced( $post_id ) ) { - $this->prep_upload( $post_id ); - } + delete_post_meta( $post_id, Sync::META_KEYS['sync_error'] ); + delete_post_meta( $post_id, Sync::META_KEYS['public_id'] ); + delete_post_meta( $post_id, Sync::META_KEYS['pending'] ); + $file = get_attached_file( $post_id ); + wp_generate_attachment_metadata( $post_id, $file ); + $this->prep_upload( $post_id ); } break; } From 640122ca8118acbf57eead990fcac40c2b3d3764 Mon Sep 17 00:00:00 2001 From: David Cramer Date: Mon, 8 Jun 2020 15:25:11 +0200 Subject: [PATCH 5/6] version bump --- .../cloudinary.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/cloudinary.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/cloudinary.php index 23c09bc93..e3c28c44f 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/cloudinary.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/cloudinary.php @@ -3,7 +3,7 @@ * Plugin Name: Cloudinary * Plugin URI: https://cloudinary.com/documentation/wordpress_integration * Description: With the Cloudinary plugin, you can upload and manage your media assets in the cloud, then deliver them to your users through a fast content delivery network, improving your website’s loading speed and overall user experience. Apply multiple transformations and take advantage of a full digital asset management solution without leaving WordPress. - * Version: 2.1.1 + * Version: 2.1.2 * Author: Cloudinary Ltd., XWP * Author URI: https://cloudinary.com/ * License: GPLv2+ From 499c00c6436159e1e82a3bddd6716dacb32d22c9 Mon Sep 17 00:00:00 2001 From: asisayag Date: Tue, 9 Jun 2020 14:52:48 +0300 Subject: [PATCH 6/6] Version 2.1.2 --- .../readme.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/readme.txt b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/readme.txt index 29bc2d635..2aeb0fd81 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/readme.txt +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/readme.txt @@ -108,6 +108,15 @@ You can read the plugin [documentation](https://cloudinary.com/documentation/wor 9. Easily Configure Your Account == Changelog == + += 2.1.2 (09 Jun 2020) = + +Fixes and Improvements: + + * Fixed cases where the image size were added to the URL. + * Added support to dashes ('-') in the connection string. + * Added an option to re-sync a single asset to Cloudinary. + = 2.1.1 (01 Jun 2020) = New features: