diff --git a/amp.module b/amp.module index 5729d6c..d2b52cc 100644 --- a/amp.module +++ b/amp.module @@ -692,12 +692,21 @@ function amp_node_view($node, $view_mode, $langcode) { } } - if (!empty($image_url) && $image_info = image_get_info($image_url)) { + // Obtain URI of absolute URL. + $uri = 'public://'; + $public_stream_base_url= file_create_url($uri); + $image_uri = ''; + if (substr($image_url, 0, strlen($public_stream_base_url)) == $public_stream_base_url) { + $image_uri = file_build_uri(substr($image_url, strlen($public_stream_base_url))); + } + + if (!empty($image_url) && FALSE !== image_get_info($image_uri)) { + $image_info = image_get_info($image_uri); $metadata_json[$name] = array( '@type' => 'ImageObject', 'url' => $image_url, - 'width' => $image_info[0], - 'height' => $image_info[1], + 'width' => $image_info['width'], + 'height' => $image_info['height'], ); } } @@ -716,8 +725,8 @@ function amp_node_view($node, $view_mode, $langcode) { $metadata_json['publisher']['logo'] = array( '@type' => 'ImageObject', 'url' => $logo_url, - 'width' => $logo_info[0], - 'height' => $logo_info[1], + 'width' => $logo_info['width'], + 'height' => $logo_info['height'], ); } }