| @@ -839,17 +839,18 @@ | ||
| 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 | |
| 844 | - $attachment_id = attachment_url_to_postid($image_url); | |
| 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); | |
| 845 | 846 | if ($attachment_id) { |
| 846 | - $image_data = wp_get_attachment_image_src($attachment_id, 'full'); | |
| 847 | + $image_file = Attachment_Lookup::describe($attachment_id, $image_url); | |
| 847 | 848 | // SVGs report 0x0 — omit the dimensions rather than emitting |
| 848 | 849 | // zeroes, which invalidate the ImageObject. |
| 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]; | |
| 850 | + if ($image_file['width'] > 0 && $image_file['height'] > 0) { | |
| 851 | + $image_schema['width'] = $image_file['width']; | |
| 852 | + $image_schema['height'] = $image_file['height']; | |
| 852 | 853 | } |
| 853 | 854 | } |
| 854 | 855 | |
| 855 | 856 | return $image_schema; |
| @@ -923,9 +924,9 @@ | ||
| 923 | 924 | 'organization_social_telegram' |
| 924 | 925 | ]; |
| 925 | 926 | |
| 926 | 927 | foreach ($social_fields as $field) { |
| 927 | - if (!empty($settings[$field]) && filter_var($settings[$field], FILTER_VALIDATE_URL)) { | |
| 928 | + if (!empty($settings[$field]) && \ThinkRank\Core\Url_Validator::is_valid($settings[$field])) { | |
| 928 | 929 | $social_profiles[] = $settings[$field]; |
| 929 | 930 | } |
| 930 | 931 | } |
| 931 | 932 | |
| @@ -1597,14 +1598,9 @@ | ||
| 1597 | 1598 | $social_profiles, |
| 1598 | 1599 | static function ($url) { |
| 1599 | 1600 | return is_string($url) |
| 1600 | 1601 | && '' !== trim($url) |
| 1601 | - && filter_var($url, FILTER_VALIDATE_URL) | |
| 1602 | - && in_array( | |
| 1603 | - strtolower((string) wp_parse_url($url, PHP_URL_SCHEME)), | |
| 1604 | - ['http', 'https'], | |
| 1605 | - true | |
| 1606 | - ); | |
| 1602 | + && \ThinkRank\Core\Url_Validator::is_http_url($url); | |
| 1607 | 1603 | } |
| 1608 | 1604 | ))); |
| 1609 | 1605 | |
| 1610 | 1606 | if (!empty($social_profiles)) { |