| @@ -1799,16 +1799,12 @@ | ||
| 1799 | 1799 | // Get image dimensions and alt text |
| 1800 | 1800 | $image_id = get_post_thumbnail_id($this->current_post_id); |
| 1801 | 1801 | $image_meta = wp_get_attachment_metadata($image_id); |
| 1802 | 1802 | if ($image_meta) { |
| 1803 | - // The `large` file being published, not the original it | |
| 1804 | - // was generated from: the metadata's own width and height | |
| 1805 | - // describe an image this tag does not point at (#847). | |
| 1806 | - $image_file = \ThinkRank\SEO\Attachment_Lookup::describe((int) $image_id, (string) $image_url); | |
| 1807 | 1803 | // SVGs (and other vector uploads) report 0x0 — emitting |
| 1808 | 1804 | // those as og:image dimensions is invalid, so skip them. |
| 1809 | - $og_width = $image_file['width']; | |
| 1810 | - $og_height = $image_file['height']; | |
| 1805 | + $og_width = isset($image_meta['width']) ? (int) $image_meta['width'] : 0; | |
| 1806 | + $og_height = isset($image_meta['height']) ? (int) $image_meta['height'] : 0; | |
| 1811 | 1807 | if ($og_width > 0 && $og_height > 0) { |
| 1812 | 1808 | echo "<meta property=\"og:image:width\" content=\"" . esc_attr($og_width) . "\" />\n"; |
| 1813 | 1809 | echo "<meta property=\"og:image:height\" content=\"" . esc_attr($og_height) . "\" />\n"; |
| 1814 | 1810 | } |
| @@ -1813,9 +1809,9 @@ | ||
| 1813 | 1809 | echo "<meta property=\"og:image:height\" content=\"" . esc_attr($og_height) . "\" />\n"; |
| 1814 | 1810 | } |
| 1815 | 1811 | // Derive the real mime type instead of hardcoding image/jpeg, |
| 1816 | 1812 | // which mislabels PNG/WebP featured images. |
| 1817 | - $image_mime = $image_file['type']; | |
| 1813 | + $image_mime = get_post_mime_type($image_id); | |
| 1818 | 1814 | if ($image_mime) { |
| 1819 | 1815 | echo "<meta property=\"og:image:type\" content=\"" . esc_attr($image_mime) . "\" />\n"; |
| 1820 | 1816 | } |
| 1821 | 1817 | } |