diff --git a/wp/headless-wp/includes/classes/Integrations/Gutenberg.php b/wp/headless-wp/includes/classes/Integrations/Gutenberg.php index 6c9174d10..8038f0ba6 100644 --- a/wp/headless-wp/includes/classes/Integrations/Gutenberg.php +++ b/wp/headless-wp/includes/classes/Integrations/Gutenberg.php @@ -30,8 +30,8 @@ public function register() { * @return int */ protected function get_image_by_url( $url ) { - if ( function_exists( '\wpcom_vip_url_to_postid' ) ) { - return \wpcom_vip_url_to_postid( $url ); + if ( function_exists( '\wpcom_vip_attachment_url_to_postid' ) ) { + return \wpcom_vip_attachment_url_to_postid( $url ); } $cache_key = sprintf( 'get_image_by_%s', md5( $url ) ); @@ -74,8 +74,12 @@ public function ensure_image_has_dimensions( $block_content, $block ) { if ( $doc->next_tag( 'img' ) ) { $src = $doc->get_attribute( 'src' ); - // check if $src is a image hosted in the current wp install - if ( strpos( $src, get_site_url() ) !== false && empty( $block['attrs']['id'] ) ) { + + $src_check = str_replace( 'http://', 'https://', $src ); + $site_url = str_replace( 'http://', 'https://', get_site_url() ); + + // check if $src is a image hosted in the current wp install and block has no ID + if ( str_contains( $src_check, $site_url ) && empty( $block['attrs']['id'] ) ) { $image_id = $this->get_image_by_url( $src ); if ( $image_id ) {