From b71c455f8202553c9182d4555f1482e163a6a1be Mon Sep 17 00:00:00 2001 From: GiannisTzonis Date: Mon, 21 Oct 2024 15:08:49 +0300 Subject: [PATCH] Prevent lang code to be included in URL for images --- includes/lib/transifex-live-integration-picker.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/includes/lib/transifex-live-integration-picker.php b/includes/lib/transifex-live-integration-picker.php index 315a56b..158e570 100644 --- a/includes/lib/transifex-live-integration-picker.php +++ b/includes/lib/transifex-live-integration-picker.php @@ -83,6 +83,14 @@ function render() { $source_url_path = (substr($url_path, 0, strlen($lang)) === $lang) ? substr($url_path, strlen($lang)) : $url_path; } $url_map = Transifex_Live_Integration_Common::generate_language_url_map( $source_url_path, $this->tokenized_url, $this->language_map ); + + // Ensure image URLs are not modified by the language prefix + foreach ($url_map as $key => $url) { + if (strpos($url, '/wp-content/uploads/') !== false) { + continue; + } + $url_map[$key] = rtrim($url, '/') . '/'; + } $site_url_slash_maybe = (new Transifex_Live_Integration_WP_Services())->get_site_url($this->is_subdirectory_install); $site_url = rtrim( $site_url_slash_maybe, '/' ) . '/'; $source_url_path = ltrim( $source_url_path, '/' );