diff --git a/php/class-media.php b/php/class-media.php index 85971e9a9..8304a7076 100644 --- a/php/class-media.php +++ b/php/class-media.php @@ -955,7 +955,7 @@ public function default_image_freeform_transformations( $default ) { * @return string The converted URL. */ public function cloudinary_url( $attachment_id, $size = array(), $transformations = array(), $cloudinary_id = null, $overwrite_transformations = false ) { - if ( ! ( $cloudinary_id ) ) { + if ( ! $cloudinary_id ) { $cloudinary_id = $this->cloudinary_id( $attachment_id ); if ( ! $cloudinary_id ) { return null; @@ -1159,7 +1159,7 @@ public function get_cloudinary_id( $attachment_id ) { * * @param int $attachment_id The ID to get Cloudinary id for. * - * @return string|false the ID or null if not existing. + * @return string|false the ID or false if not existing. */ public function cloudinary_id( $attachment_id ) { static $cloudinary_ids = array(); @@ -1170,8 +1170,8 @@ public function cloudinary_id( $attachment_id ) { } if ( ! $this->is_media( $attachment_id ) ) { - $cloudinary_ids[ $attachment_id ] = null; - return null; + $cloudinary_ids[ $attachment_id ] = false; + return false; } if ( ! $this->sync->is_synced( $attachment_id ) && ! defined( 'REST_REQUEST' ) ) { @@ -1857,7 +1857,7 @@ public function get_post_meta( $post_id, $key = '', $single = false ) { } } if ( '' !== $key ) { - $meta = isset( $meta[ $key ] ) ? $meta[ $key ] : ''; + $meta = isset( $meta[ $key ] ) ? $meta[ $key ] : null; } return $single ? $meta : (array) $meta; diff --git a/php/class-report.php b/php/class-report.php index fe7beb66e..b9de63d41 100644 --- a/php/class-report.php +++ b/php/class-report.php @@ -163,7 +163,8 @@ public function image_meta_viewer() { */ public function render( $post ) { if ( 'attachment' === $post->post_type ) { - $meta = wp_get_attachment_metadata( $post->ID ); + $sync = $this->plugin->get_component( 'sync' ); + $meta = get_post_meta( $post->ID, $sync::META_KEYS['cloudinary'], true ); $args = array( 'type' => 'tag', diff --git a/php/class-sync.php b/php/class-sync.php index a8dadfe19..63589bb54 100644 --- a/php/class-sync.php +++ b/php/class-sync.php @@ -499,7 +499,7 @@ public function setup_sync_base_struct() { 'priority' => 25, 'sync' => array( $this->managers['upload'], 'explicit_update' ), 'validate' => function ( $attachment_id ) { - $delivery = $this->managers['media']->get_post_meta( $attachment_id, self::META_KEYS['delivery'] ); + $delivery = $this->managers['media']->get_post_meta( $attachment_id, self::META_KEYS['delivery'], true ); return empty( $delivery ) || 'upload' === $delivery; }, diff --git a/php/connect/class-api.php b/php/connect/class-api.php index 45e43b852..147412e11 100644 --- a/php/connect/class-api.php +++ b/php/connect/class-api.php @@ -396,13 +396,13 @@ function_exists( 'wp_get_original_image_url' ) && } else { $file_url = wp_get_attachment_url( $attachment_id ); } - if ( ! is_local_attachment( $attachment_id ) ) { + $media = get_plugin_instance()->get_component( 'media' ); + if ( ! $media->is_local_media( $attachment_id ) ) { $disable_https_fetch = false; // Remote can upload via url. // translators: variable is thread name and queue size. $action_message = sprintf( __( 'Uploading remote url: %1$s.', 'cloudinary' ), $file_url ); do_action( '_cloudinary_queue_action', $action_message ); } - $media = get_plugin_instance()->get_component( 'media' ); $tempfile = false; if ( $media && $media->is_cloudinary_url( $file_url ) ) { // If this is a Cloudinary URL, then we can use it to fetch from that location.