PluginProbe
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO / 2.13.0
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO v2.13.0
2.13.0 2.12.0 2.11.0 2.10.0 2.9.0 2.8.0 2.7.0 2.6.0 2.5.0 2.4.0 2.3.0 2.2.0 2.1.1 2.1.0 2.0.2 2.0.1 2.0.0 1.32.0 1.31.0 1.30.0 1.29.0 1.28.0 1.27.0 1.26.0 1.25.0 All 54 releases
← All changes | includes/seo/class-site-identity-manager.php +18 -22 2.11.0 → 2.13.0 View file →
@@ -508,11 +508,12 @@
508 508 * Attachment ID behind a configured icon URL, or 0 when it is not ours.
509 509 *
510 510 * attachment_url_to_postid() matches _wp_attached_file, which holds the
511 511 * ORIGINAL upload path, so the URL of a generated derivative
512 - * (`logo-512.png`) returns 0 — and that is exactly what the media picker
513 - * hands back when the user chooses a size. Strip the dimension suffix and
514 - * try the original once.
512 + * (`logo-512x512.png`) returns 0 — and that is exactly what the media
513 + * picker hands back when the user chooses a size. Attachment_Lookup falls
514 + * back to the original behind it; the fallback started here and moved
515 + * there when every other image lookup turned out to need it (#847).
515 516 *
516 517 * Shared with SEO_Manager's site-icon filter so both sides of the feature
517 518 * agree on which attachment a configured URL means.
518 519 *
@@ -521,21 +522,9 @@
521 522 * @param string $url Configured icon URL.
522 523 * @return int Attachment ID, or 0.
523 524 */
524 525 public static function icon_attachment_id(string $url): int {
525 - $attachment_id = (int) attachment_url_to_postid($url);
526 -
527 - if ($attachment_id) {
528 - return $attachment_id;
529 - }
530 -
531 - $original = preg_replace('/-\d+x\d+(?=\.[a-zA-Z0-9]+$)/', '', $url);
532 -
533 - if (is_string($original) && $original !== $url) {
534 - return (int) attachment_url_to_postid($original);
535 - }
536 -
537 - return 0;
526 + return Attachment_Lookup::id_from_url($url);
538 527 }
539 528
540 529 /**
541 530 * Which ICON_SIZES derivatives this attachment still needs.
@@ -1432,13 +1421,16 @@
1432 1421 }
1433 1422
1434 1423 // Additional logo analysis for local images
1435 1424 if (!empty($logo_url) && filter_var($logo_url, FILTER_VALIDATE_URL)) {
1436 - $attachment_id = attachment_url_to_postid($logo_url);
1425 + $attachment_id = Attachment_Lookup::id_from_url($logo_url);
1437 1426 if ($attachment_id) {
1438 1427 $image_meta = wp_get_attachment_metadata($attachment_id);
1439 - $width = isset($image_meta['width']) ? (int) $image_meta['width'] : 0;
1440 - $height = isset($image_meta['height']) ? (int) $image_meta['height'] : 0;
1428 + // The configured file's own size — a logo picked at a generated
1429 + // size is not as large as the upload behind it.
1430 + $logo_file = Attachment_Lookup::describe($attachment_id, $logo_url);
1431 + $width = $logo_file['width'];
1432 + $height = $logo_file['height'];
1441 1433
1442 1434 // SVG logos store 0x0 metadata — no dimension/ratio analysis
1443 1435 // is possible (and dividing by 0 is fatal).
1444 1436 if ($image_meta && $width > 0 && $height > 0) {
@@ -2914,8 +2906,10 @@
2914 2906 return [
2915 2907 // Title formats, one per context.
2916 2908 'homepage_title', 'post_title', 'page_title', 'category_title',
2917 2909 'tag_title', 'author_title', 'search_title', 'archive_title',
2910 + // The blog-index homepage's meta description (#897).
2911 + 'homepage_description',
2918 2912 // Breadcrumbs.
2919 2913 'breadcrumb_prefix', 'show_current_page', 'breadcrumb_use_seo_title',
2920 2914 // Identity, as written by the setup wizard and the importers.
2921 2915 'alternate_name', 'identity_type', 'represents',
@@ -4261,18 +4255,20 @@
4261 4255 return $optimization;
4262 4256 }
4263 4257
4264 4258 // Check if it's a local image
4265 - $attachment_id = attachment_url_to_postid($value);
4259 + $attachment_id = Attachment_Lookup::id_from_url($value);
4266 4260 if ($attachment_id) {
4267 4261 $image_meta = wp_get_attachment_metadata($attachment_id);
4268 4262
4269 4263 if ($image_meta && isset($image_meta['width'], $image_meta['height'])) {
4270 - // Check recommended size
4264 + // Check recommended size, against the configured file itself
4265 + // rather than the upload it may have been generated from.
4271 4266 if (isset($config['recommended_size'])) {
4272 4267 [$rec_width, $rec_height] = explode('x', $config['recommended_size']);
4268 + $image_file = Attachment_Lookup::describe($attachment_id, $value);
4273 4269
4274 - if ((int) $image_meta['width'] !== (int) $rec_width || (int) $image_meta['height'] !== (int) $rec_height) {
4270 + if ($image_file['width'] !== (int) $rec_width || $image_file['height'] !== (int) $rec_height) {
4275 4271 $optimization['suggestions'][] = "Consider using {$config['recommended_size']} size for optimal {$element}";
4276 4272 }
4277 4273 }
4278 4274