/** * Push to URL pairs. * * @param array $url_pairs * @param int $attachment_id * @param string $find * @param array $to_cache */ protected function push_to_url_pairs(&$url_pairs, $attachment_id, $find, &$to_cache) { $find_full = $this->as3cf->remove_size_from_filename($find); $find_full = $this->normalize_find_value($this->as3cf->maybe_remove_query_string($find_full)); $find_size = $this->normalize_find_value($this->as3cf->maybe_remove_query_string($find)); // Cache find URLs even if no replacement. $to_cache[$find_full] = $attachment_id; if (wp_basename($find_full) !== wp_basename($find_size)) { $to_cache[$find_size] = $attachment_id; } $replace_full = $this->get_url($attachment_id); // Replacement URL can't be found. if (!$replace_full) { return; } $size = $this->get_size_string_from_url($attachment_id, $find); $replace_size = $this->get_url($attachment_id, $size); $parts = parse_url($find); if (!isset($parts['scheme'])) { $replace_full = $this->as3cf->remove_scheme($replace_full); $replace_size = $this->as3cf->remove_scheme($replace_size); } // Find and replace full version $url_pairs[$find_full] = $replace_full; // Find and replace sized version if (wp_basename($find_full) !== wp_basename($find_size)) { $url_pairs[$find_size] = $replace_size; } // Prime cache, when filtering the opposite way $replace_full = $this->as3cf->maybe_remove_query_string($replace_full); $replace_size = $this->as3cf->maybe_remove_query_string($replace_size); $to_cache[$this->normalize_find_value($replace_full)] = $attachment_id; $to_cache[$this->normalize_find_value($replace_size)] = $attachment_id; }