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
17 changes: 8 additions & 9 deletions php/class-media.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ public function get_syncable_delivery_types() {
*/
return apply_filters( 'cloudinary_syncable_delivery_types', $types );
}

/**
* Get convertible extensions and converted file types.
*
Expand Down Expand Up @@ -273,9 +274,10 @@ public function is_media( $attachment_id ) {
*/
public function is_local_media( $attachment_id ) {
$local_host = wp_parse_url( get_site_url(), PHP_URL_HOST );
$media_host = wp_parse_url( get_the_guid( $attachment_id ), PHP_URL_HOST );
$guid = get_the_guid( $attachment_id );
$media_host = wp_parse_url( $guid, PHP_URL_HOST );

return $local_host === $media_host;
return $local_host === $media_host || $this->is_cloudinary_url( $guid );
}

/**
Expand Down Expand Up @@ -1379,7 +1381,7 @@ public function is_cloudinary_url( $url ) {
* @return bool
*/
public function is_cloudinary_sync_folder( $url ) {
$path = wp_parse_url( $url, PHP_URL_PATH );
$path = wp_parse_url( $url, PHP_URL_PATH );
$parts = explode( '/', $path );

// Remove public id and file name.
Expand Down Expand Up @@ -1714,18 +1716,15 @@ public function media_column_value( $column_name, $attachment_id ) {
?>
<span class="dashicons-cloudinary <?php echo esc_attr( $status['state'] ); ?>" title="<?php echo esc_attr( $status['note'] ); ?>"></span>
<?php
endif;
if ( ! $this->is_local_media( $attachment_id ) ) :
elseif ( ! $this->is_local_media( $attachment_id ) ) :
?>
<span class="dashicons-cloudinary info" title="<?php esc_attr_e( 'Not syncable. This is an external media.', 'cloudinary' ); ?>"></span>
<?php
endif;
if ( 'fetch' === $this->get_media_delivery( $attachment_id ) ) :
elseif ( 'fetch' === $this->get_media_delivery( $attachment_id ) ) :
?>
<span class="dashicons-cloudinary info" title="<?php esc_attr_e( 'This media is Fetch type.', 'cloudinary' ); ?>"></span>
<?php
endif;
if ( 'sprite' === $this->get_media_delivery( $attachment_id ) ) :
elseif ( 'sprite' === $this->get_media_delivery( $attachment_id ) ) :
?>
<span class="dashicons-cloudinary info" title="<?php esc_attr_e( 'This media is Sprite type.', 'cloudinary' ); ?>"></span>
<?php
Expand Down
8 changes: 4 additions & 4 deletions php/class-sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,14 +302,14 @@ public function get_signature( $attachment_id, $cached = true ) {
/**
* Filter the get signature of the asset.
*
* @hook cloudinary_get_signature
* @hook cloudinary_get_signature
*
* @param $signature {array} The attachment signature.
* @param $return {array} The attachment signature.
* @param $attachment_id {int} The attachment ID.
*
* @return {array}
*/
$return = apply_filters( 'cloudinary_get_signature', $signatures[ $attachment_id ], $attachment_id );
$return = apply_filters( 'cloudinary_get_signature', $return, $attachment_id );

return $return;
}
Expand Down Expand Up @@ -496,7 +496,7 @@ public function setup_sync_base_struct() {
),
'meta_cleanup' => array(
'generate' => function ( $attachment_id ) {
$meta = $this->managers['media']->get_post_meta( $attachment_id );
$meta = $this->managers['media']->get_post_meta( $attachment_id );
$return = false;
foreach ( $meta as $key => $value ) {
if ( get_post_meta( $attachment_id, $key, true ) === $value ) {
Expand Down
2 changes: 1 addition & 1 deletion php/media/class-upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function convert_cloudinary_version( $attachment_id ) {
// Remove extension.
$path = pathinfo( $public_id );
$public_id = str_replace( $path['basename'], $path['filename'], $public_id );
$this->media->update_post_meta( $attachment_id, Sync::META_KEYS['public_id'], $public_id );
update_post_meta( $attachment_id, Sync::META_KEYS['public_id'], $public_id );
$this->media->update_post_meta( $attachment_id, Sync::META_KEYS['version'], $asset_version );
if ( ! empty( $asset_transformations ) ) {
$this->media->update_post_meta( $attachment_id, Sync::META_KEYS['transformation'], $asset_transformations );
Expand Down