| @@ -839,18 +839,17 @@ | ||
| 839 | 839 | '@type' => 'ImageObject', |
| 840 | 840 | 'url' => $image_url |
| 841 | 841 | ]; |
| 842 | 842 | |
| 843 | - // Try to get image dimensions if it's a WordPress attachment — those | |
| 844 | - // of the file this URL names, which need not be the original upload. | |
| 845 | - $attachment_id = Attachment_Lookup::id_from_url($image_url); | |
| 843 | + // Try to get image dimensions if it's a WordPress attachment | |
| 844 | + $attachment_id = attachment_url_to_postid($image_url); | |
| 846 | 845 | if ($attachment_id) { |
| 847 | - $image_file = Attachment_Lookup::describe($attachment_id, $image_url); | |
| 846 | + $image_data = wp_get_attachment_image_src($attachment_id, 'full'); | |
| 848 | 847 | // SVGs report 0x0 — omit the dimensions rather than emitting |
| 849 | 848 | // zeroes, which invalidate the ImageObject. |
| 850 | - if ($image_file['width'] > 0 && $image_file['height'] > 0) { | |
| 851 | - $image_schema['width'] = $image_file['width']; | |
| 852 | - $image_schema['height'] = $image_file['height']; | |
| 849 | + if ($image_data && (int) $image_data[1] > 0 && (int) $image_data[2] > 0) { | |
| 850 | + $image_schema['width'] = (int) $image_data[1]; | |
| 851 | + $image_schema['height'] = (int) $image_data[2]; | |
| 853 | 852 | } |
| 854 | 853 | } |
| 855 | 854 | |
| 856 | 855 | return $image_schema; |