Skip to content

Commit b8f7af1

Browse files
committed
address PR issues
1 parent 4427e71 commit b8f7af1

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-media.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1812,7 +1812,7 @@ public function setup() {
18121812
* @return array
18131813
*/
18141814
public function match_file_name_with_cloudinary_source( $image_meta, $attachment_id ) {
1815-
if ( is_array( $image_meta ) && isset( $image_meta['file'] ) && $this->has_public_id( $attachment_id ) ) {
1815+
if ( is_array( $image_meta ) && ! empty( $image_meta['file'] ) && $this->has_public_id( $attachment_id ) ) {
18161816
$cld_file = 'v' . $this->get_cloudinary_version( $attachment_id ) . '/' . $this->get_cloudinary_id( $attachment_id );
18171817
if ( false === strpos( $image_meta['file'], $cld_file ) ) {
18181818
$image_meta['file'] = $cld_file;

cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media/class-filter.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -712,19 +712,15 @@ public function filter_image_block_pre_render( $block, $source_block ) {
712712
public function init_rest_filters() {
713713
// Gutenberg compatibility.
714714
add_filter( 'rest_prepare_attachment', array( $this, 'filter_attachment_for_rest' ) );
715-
$types = get_post_types_by_support( 'editor' );
716-
$filter = $this;
717-
array_map(
718-
function ( $type ) use ( $filter ) {
719-
$post_type = get_post_type_object( $type );
720-
// Check if this is a rest supported type.
721-
if ( true === $post_type->show_in_rest ) {
722-
// Add filter only to rest supported types.
723-
add_filter( 'rest_prepare_' . $type, array( $filter, 'pre_filter_rest_content' ), 10, 3 );
724-
}
725-
},
726-
$types
727-
);
715+
$types = get_post_types_by_support( 'editor' );
716+
foreach ( $types as $type ) {
717+
$post_type = get_post_type_object( $type );
718+
// Check if this is a rest supported type.
719+
if ( true === $post_type->show_in_rest ) {
720+
// Add filter only to rest supported types.
721+
add_filter( 'rest_prepare_' . $type, array( $this, 'pre_filter_rest_content' ), 10, 3 );
722+
}
723+
}
728724
}
729725

730726
/**

0 commit comments

Comments
 (0)