Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}

Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,24 +97,31 @@ 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(
'<a href="%s" aria-label="%s">%s</a>',
$action_url,
/* translators: %s: Attachment title. */
esc_attr( sprintf( __( 'Push to Cloudinary &#8220;%s&#8221;' ), 'asd' ) ),
__( 'Push to Cloudinary', 'cloudinary' )
);
} else {
$actions['cloudinary-push'] = sprintf(
'<a href="%s" aria-label="%s">%s</a>',
$action_url,
/* translators: %s: Attachment title. */
esc_attr( sprintf( __( 'Push to Cloudinary &#8220;%s&#8221;' ), 'asd' ) ),
__( 'Re-sync to Cloudinary', 'cloudinary' )
);
}
}

Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down