| @@ -1533,9 +1533,21 @@ | ||
| 1533 | 1533 | $data['title'] = $fallback_title; |
| 1534 | 1534 | } else { |
| 1535 | 1535 | $data['title'] = $blogname; |
| 1536 | 1536 | } |
| 1537 | - $data['description'] = $settings['og_description'] ?? get_bloginfo('description'); | |
| 1537 | + // Same rule as the title above: the shipped default (the tagline) | |
| 1538 | + // is not a choice, so the homepage's meta description wins over | |
| 1539 | + // it. Without this an imported or hand-set homepage description | |
| 1540 | + // printed as the meta description while og:/twitter:description | |
| 1541 | + // kept the tagline (#897). | |
| 1542 | + $og_description = (string) ($settings['og_description'] ?? ''); | |
| 1543 | + if ($og_description !== '' && $og_description !== get_bloginfo('description')) { | |
| 1544 | + $data['description'] = $og_description; | |
| 1545 | + } elseif ($fallback_description !== null && $fallback_description !== '') { | |
| 1546 | + $data['description'] = $fallback_description; | |
| 1547 | + } else { | |
| 1548 | + $data['description'] = get_bloginfo('description'); | |
| 1549 | + } | |
| 1538 | 1550 | // Use home_url('/') so og:url matches the homepage canonical |
| 1539 | 1551 | // (class-seo-manager.php) and the WebSite schema, which both include |
| 1540 | 1552 | // the trailing slash. A bare home_url() would key a different URL in |
| 1541 | 1553 | // social caches than the canonical. |
| @@ -1842,8 +1854,12 @@ | ||
| 1842 | 1854 | $image_id = get_post_thumbnail_id($post); |
| 1843 | 1855 | if ($image_id) { |
| 1844 | 1856 | $image_data = wp_get_attachment_image_src($image_id, 'large'); |
| 1845 | 1857 | if (!empty($image_data[0])) { |
| 1858 | + // The ID is in hand here and gone once this returns a | |
| 1859 | + // bare URL; say so rather than have the tag builders look | |
| 1860 | + // it up again, twice, with a URL core cannot match (#847). | |
| 1861 | + Attachment_Lookup::remember((string) $image_data[0], (int) $image_id); | |
| 1846 | 1862 | return $image_data[0]; |
| 1847 | 1863 | } |
| 1848 | 1864 | } |
| 1849 | 1865 | } |
| @@ -1890,8 +1906,12 @@ | ||
| 1890 | 1906 | $image_id = get_post_thumbnail_id($post); |
| 1891 | 1907 | if ($image_id) { |
| 1892 | 1908 | $image_data = wp_get_attachment_image_src($image_id, 'large'); |
| 1893 | 1909 | if (!empty($image_data[0])) { |
| 1910 | + // The ID is in hand here and gone once this returns a | |
| 1911 | + // bare URL; say so rather than have the tag builders look | |
| 1912 | + // it up again, twice, with a URL core cannot match (#847). | |
| 1913 | + Attachment_Lookup::remember((string) $image_data[0], (int) $image_id); | |
| 1894 | 1914 | return $image_data[0]; |
| 1895 | 1915 | } |
| 1896 | 1916 | } |
| 1897 | 1917 | } |
| @@ -2184,21 +2204,23 @@ | ||
| 2184 | 2204 | if (empty($image_url)) { |
| 2185 | 2205 | return $image_data; |
| 2186 | 2206 | } |
| 2187 | 2207 | |
| 2188 | - // Get image metadata | |
| 2189 | - $attachment_id = attachment_url_to_postid($image_url); | |
| 2208 | + // Get image metadata. The dimensions are those of the file this URL | |
| 2209 | + // names — usually a generated size — not of the original upload, so | |
| 2210 | + // the width and height published beside it describe the same image. | |
| 2211 | + $attachment_id = Attachment_Lookup::id_from_url($image_url); | |
| 2190 | 2212 | if ($attachment_id) { |
| 2191 | 2213 | $image_meta = wp_get_attachment_metadata($attachment_id); |
| 2192 | 2214 | $image_alt = get_post_meta($attachment_id, '_wp_attachment_image_alt', true); |
| 2193 | - $mime_type = get_post_mime_type($attachment_id); | |
| 2215 | + $image_file = Attachment_Lookup::describe($attachment_id, $image_url); | |
| 2194 | 2216 | |
| 2195 | 2217 | if ($image_meta && isset($image_meta['width'], $image_meta['height'])) { |
| 2196 | - $width = (int) $image_meta['width']; | |
| 2197 | - $height = (int) $image_meta['height']; | |
| 2218 | + $width = $image_file['width']; | |
| 2219 | + $height = $image_file['height']; | |
| 2198 | 2220 | |
| 2199 | 2221 | $image_data['alt'] = $image_alt ?: ''; |
| 2200 | - $image_data['type'] = $mime_type ?: ''; | |
| 2222 | + $image_data['type'] = $image_file['type']; | |
| 2201 | 2223 | |
| 2202 | 2224 | // SVGs and other vector uploads store 0x0 metadata. Dimension |
| 2203 | 2225 | // checks are meaningless there and dividing by 0 is fatal. |
| 2204 | 2226 | if ($width > 0 && $height > 0) { |
| @@ -2250,8 +2272,9 @@ | ||
| 2250 | 2272 | $custom_logo_id = get_theme_mod('custom_logo'); |
| 2251 | 2273 | if ($custom_logo_id) { |
| 2252 | 2274 | $logo_data = wp_get_attachment_image_src($custom_logo_id, 'large'); |
| 2253 | 2275 | if ($logo_data) { |
| 2276 | + Attachment_Lookup::remember((string) $logo_data[0], (int) $custom_logo_id); | |
| 2254 | 2277 | return $logo_data[0]; |
| 2255 | 2278 | } |
| 2256 | 2279 | } |
| 2257 | 2280 | |
| @@ -2259,8 +2282,9 @@ | ||
| 2259 | 2282 | $site_icon_id = get_option('site_icon'); |
| 2260 | 2283 | if ($site_icon_id) { |
| 2261 | 2284 | $icon_data = wp_get_attachment_image_src($site_icon_id, 'large'); |
| 2262 | 2285 | if ($icon_data) { |
| 2286 | + Attachment_Lookup::remember((string) $icon_data[0], (int) $site_icon_id); | |
| 2263 | 2287 | return $icon_data[0]; |
| 2264 | 2288 | } |
| 2265 | 2289 | } |
| 2266 | 2290 | |
| @@ -3017,13 +3041,14 @@ | ||
| 3017 | 3041 | return $validation; |
| 3018 | 3042 | } |
| 3019 | 3043 | |
| 3020 | 3044 | // Get image metadata if it's a local attachment |
| 3021 | - $attachment_id = attachment_url_to_postid($image_url); | |
| 3045 | + $attachment_id = Attachment_Lookup::id_from_url($image_url); | |
| 3022 | 3046 | if ($attachment_id) { |
| 3023 | 3047 | $image_meta = wp_get_attachment_metadata($attachment_id); |
| 3024 | - $meta_width = isset($image_meta['width']) ? (int) $image_meta['width'] : 0; | |
| 3025 | - $meta_height = isset($image_meta['height']) ? (int) $image_meta['height'] : 0; | |
| 3048 | + $image_file = Attachment_Lookup::describe($attachment_id, $image_url); | |
| 3049 | + $meta_width = $image_file['width']; | |
| 3050 | + $meta_height = $image_file['height']; | |
| 3026 | 3051 | |
| 3027 | 3052 | // SVGs and other vector uploads store 0x0 metadata — skip the |
| 3028 | 3053 | // dimension/ratio checks instead of dividing by 0. |
| 3029 | 3054 | if ($image_meta && $meta_width > 0 && $meta_height > 0) { |