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+
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',
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..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
@@ -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 );
}
}
@@ -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;
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;
}
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: