Skip to content

Commit 31d5d8f

Browse files
authored
Merge pull request #947 from cloudinary/hotfix/3.1.8-build-2
Hotfix/3.1.8 build 2
2 parents 5aeba95 + ec24c8d commit 31d5d8f

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

php/connect/class-api.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ public function upload_large( $attachment_id, $args ) {
455455
if ( is_wp_error( $result ) ) {
456456
break;
457457
}
458-
$index ++;
458+
++$index;
459459
}
460460
fclose( $src ); //phpcs:ignore
461461
unlink( $temp_file_name ); //phpcs:ignore
@@ -464,7 +464,6 @@ public function upload_large( $attachment_id, $args ) {
464464
}
465465

466466
return $result;
467-
468467
}
469468

470469
/**
@@ -505,7 +504,20 @@ public function upload( $attachment_id, $args, $headers = array(), $try_remote =
505504
$args = $this->clean_args( $args );
506505
$disable_https_fetch = get_transient( '_cld_disable_http_upload' );
507506

508-
if ( function_exists( 'wp_get_original_image_url' ) && wp_attachment_is_image( $attachment_id ) ) {
507+
/**
508+
* Whether to use the original image URL.
509+
*
510+
* @hook cloudinary_use_original_image
511+
* @since 3.1.8
512+
* @default true
513+
*
514+
* @param $use_original {bool} The default value.
515+
* @param $attachment_id {int} The attachment ID.
516+
*
517+
* @return {bool}
518+
*/
519+
$use_original = apply_filters( 'cloudinary_use_original_image', true, $attachment_id );
520+
if ( $use_original && function_exists( 'wp_get_original_image_url' ) && wp_attachment_is_image( $attachment_id ) ) {
509521
$file_url = wp_get_original_image_url( $attachment_id );
510522
} else {
511523
$file_url = wp_get_attachment_url( $attachment_id );
@@ -535,7 +547,7 @@ public function upload( $attachment_id, $args, $headers = array(), $try_remote =
535547
// We should have the file in args at this point, but if the transient was set, it will be defaulting here.
536548
if ( empty( $args['file'] ) ) {
537549
if ( wp_attachment_is_image( $attachment_id ) ) {
538-
$get_path_func = function_exists( 'wp_get_original_image_path' ) ? 'wp_get_original_image_path' : 'get_attached_file';
550+
$get_path_func = $use_original && function_exists( 'wp_get_original_image_path' ) ? 'wp_get_original_image_path' : 'get_attached_file';
539551
$args['file'] = call_user_func( $get_path_func, $attachment_id );
540552
} else {
541553
$args['file'] = get_attached_file( $attachment_id );
@@ -898,7 +910,7 @@ public function get_public_id( $attachment_id, $args = array(), $original_public
898910
)
899911
) {
900912

901-
$parts = explode( '/', $public_id );
913+
$parts = explode( '/', $public_id );
902914
$filename = end( $parts );
903915

904916
/**
@@ -1010,5 +1022,4 @@ private function call( $url, $args = array(), $method = 'get' ) {
10101022

10111023
return $result;
10121024
}
1013-
10141025
}

php/media/class-gallery.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Cloudinary\REST_API;
1414
use Cloudinary\Settings_Component;
1515
use Cloudinary\Utils;
16+
use WP_Screen;
1617

1718
/**
1819
* Class Gallery.
@@ -114,6 +115,11 @@ public function __construct( Plugin $plugin ) {
114115
* @return array
115116
*/
116117
public function get_config() {
118+
$screen = null;
119+
120+
if ( function_exists( 'get_current_screen' ) ) {
121+
$screen = get_current_screen();
122+
}
117123

118124
$config = ! empty( $this->settings->get_value( 'gallery_config' ) ) ?
119125
$this->settings->get_value( 'gallery_config' ) :
@@ -133,7 +139,11 @@ public function get_config() {
133139

134140
$credentials = $this->plugin->components['connect']->get_credentials();
135141

136-
if ( ! empty( $credentials['cname'] ) ) {
142+
// Do not use privateCdn and secureDistribution on gallery settings page.
143+
if (
144+
! empty( $credentials['cname'] )
145+
&& ( ! $screen instanceof WP_Screen || 'cloudinary_page_cloudinary_gallery' !== $screen->id )
146+
) {
137147
$config['secureDistribution'] = $credentials['cname'];
138148
$config['privateCdn'] = true;
139149
}

ui-definitions/settings-pages.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@
225225
'sidebar' => true,
226226
array(
227227
'type' => 'panel',
228-
'title' => __( 'Help Centre', 'cloudinary' ),
228+
'title' => __( 'Help Center', 'cloudinary' ),
229229
array(
230230
'type' => 'tag',
231231
'element' => 'h4',

0 commit comments

Comments
 (0)