Skip to content Skip to sidebar

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client was experiencing issues with document file paths being incorrectly updated to dead links on translated versions of their website. They were using a custom path (/docs/) for document files instead of the standard WordPress uploads directory. Additionally, there were concerns about untranslated media items appearing in the WPML translation interface and the impact of toggling the 'Automatically detect best options for translating image texts (alt, caption, title)' setting.

Solution:
1. We confirmed that toggling the 'Automatically detect best options for translating image texts' setting should not affect existing translations or cause side effects.
2. For the custom document path issue, we recommended verifying how these paths are generated (via plugin, custom code, etc.) and suggested creating a minimal reproducible example on a test site to isolate the issue.
3. For the issue of media items not translating correctly, we advised that the client could safely re-enable the 'Automatically detect best options for translating image texts' setting.
4. Regarding the deletion of translated media items causing the original to return a 404 error, we clarified that WPML should not affect the URL of media in the default language and that this behavior was unexpected.

If this solution does not resolve your issue or seems irrelevant due to being outdated or not applicable to your case, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If further assistance is needed, please do not hesitate to open a new support ticket or contact us again at WPML support forum.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 11 replies, has 1 voice.

Last updated by Dražen 3 weeks, 1 day ago.

Assisted by: Dražen.

Author Posts
June 29, 2026 at 8:57 pm #18132333

Atul Shinh

I am opening this support ticket to follow-up on previous ticket raised. Ticket URL is
https://wpml.org/forums/topic/wpml-translation-issue-pdf-link-modified-on-translations-duplicates/

Based on recommendation in above ticket, I made changes to WPML Media settings and the solution provided helped me resolve the issue but when trying to replicate same on production environment, some settings in the same section are different.

Please help to understand which settings are best suited to resolve the issue and website performance at the same time.

Summary of website setup is below:-

The en-US is the source language and multiple non-EN languages. There is an issue with pages and posts when a file (PDF in this case) link is added in a post or page and for non-EN websites the file path is auto-updated and ends up in dead-link on translated websites.

I turned off following settings
1. WPML Settings > Media Translations > Automatically detect best options for translating image texts (alt, caption, title).
2. Uncheck the 2 check boxes for "NEW content".

But not sure on what options are better for "Existing content". Please check screenshots attached.

Best regards

For translations following structure is in place
EN-US (Source) > FR-FR (translation) > FR-CA, FR-CH (duplicates of fr-fr)

June 30, 2026 at 6:35 pm #18134214

Atul Shinh

Based on suggestions from AI assistant, I have tried the process after disabling the "Disable REST API" plugin and found no other plugins mentioned. Still the process is not able to complete and I am getting the following errors: -

# In the WP admin interface
Mark processed: Please try again (error)

# In the browser console
Failed to load resource: the server responded with a status of 502 () /wp-admin/admin-ajax.php:1

Please advice what could be reason for this. I want to make sure it is because of our Network firewall rules before going to IT team.

Screenshot 2026-06-30 at 12.36.45 PM.png
July 2, 2026 at 6:08 am #18136560

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello,

Thank you for the detailed information.

Regarding the WPML → Settings → Media Translation options, I recommend leaving all of the checkboxes enabled, including those for existing content.

As for the second issue, the **502 error** returned by `admin-ajax.php` indicates that the request is being interrupted before it can complete. Unfortunately, from the information available, it is difficult to determine the exact cause.

To narrow this down, could you please try the following?

- Enable **WP_DEBUG** and check both the WordPress debug log and your server error logs for any PHP fatal errors or server-side messages generated when the error occurs.
- If possible, temporarily switch to a default WordPress theme and deactivate all non-WPML plugins to see if the process completes successfully. This will help determine whether the issue is caused by a plugin or theme conflict.

Since you mentioned the staging site works correctly with the same WPML settings, please also compare the production and staging environments. If the only difference is the server environment, then it is very likely that a server configuration, firewall, security rule, or hosting restriction is causing the 502 response.

If the issue still occurs after these checks, please let us know the results.

Regards,
Drazen

July 6, 2026 at 3:58 pm #18143767

Atul Shinh

Hi Drazen,

Thanks for your response.

Before I try the solution you provided for AJAX related JS error, I want advice on the main issue.

The main issue is that media file paths for only document files, which use a special path on our website e.g. hidden link and not /wp-content/uploads/ in the document files, get tweaked on translated languages.

To check the solution provided by AI agent I made a minor test on PROD i.e.
WPML settings > Media translation >
"Automatically detect best options for translating image texts (alt, caption, title)"
checkbox was unchecked and no other setting was updated.

Questions
1. Can this change have some side effect on the WPML translations?
2. How can we resolve the document file path auto-updated to dead links if we are not updating the Media settings in WPML UI?

Looking forward to the response.

Thanks

Screenshot 2026-07-06 at 9.43.23 AM.png
July 6, 2026 at 6:09 pm #18143897

Atul Shinh

Hi team,

I am adding this post in addition to my previous post. Please provide responses for both. Also is there a way we can connect over chat to get some faster responses if required, to sort this matter quickly?

Problem: On live website, some untranslated MEDIA items appearing in the WPML translation interface probably because the checkbox "Automatically detect best options for translating image texts (alt, caption, title)" was turned OFF. Can we simply turn it ON to bring back to earlier stage? See screenshot, please note no other setting was changed or any process was not initiated on live.

Screenshot 2026-07-06 at 11.36.36 AM.png
July 7, 2026 at 6:13 am #18144337

Dražen
Supporter

Hello,

Thanks for the additional details.

Regarding your questions:

1. Unchecking the "Automatically detect best options for translating image texts (alt, caption, title)" option should not have any side effects on your existing translations. This setting only affects how WPML automatically determines the media translation options and does not modify your existing translated content.

2. Based on your description, the document path issue appears to be separate from the Media Translation settings. Those settings are intended for translating media metadata (such as alt text, captions, and titles) and should not automatically rewrite document URLs. Because your documents are using a custom path (/docs/) instead of the standard WordPress uploads directory, we first need to determine how are you modifying those URLs before recommending any changes?

Regarding your follow-up question, yes, you can safely enable the "Automatically detect best options for translating image texts (alt, caption, title)" option again.

As for live chat, you can open and start new chat anytime during working hours by opening new support request, and if anyone available you will be assigned to him.

In the meantime, could you please let me know how the /docs/ URLs are generated? Are they created by a plugin, custom code, or another document management solution? That information will help us narrow down why only those document paths are being modified on translated pages.

Kind regards,
Dražen

July 8, 2026 at 10:31 pm #18148164

Atul Shinh

Hi Drazen,

Thanks for your response.

Regarding configuring the custom path for uploads of document we are using custom code in functions.php to decide for which files we want /docs/ path (e.g. PDF). I have added the code snippet in the end. Please check and confirm if you think the code needs changes to support localization?

The /docs/ path works correctly on source EN website but not on translated websites. The issue is seen on Pages and Blogs posts

Page example, dead link in FAQ which you can search in source code "globalpay-for-students.pdf".

Domain for links below use convera.com as prefix
Source works: /partners/education-agents-cross-border-payments/
Works fine on translation: /fr-fr/partners/education-agents-cross-border-payments/
Not works on duplicate of fr-fr: /fr-ca/partners/education-agents-cross-border-payments/

Similarly blog:
/de/blog/cross-border-payments/fx-options-currency-risk-management/
has dead link
/wp-content/uploads/docs/convera-foreign-exchange-options-pds-en-at.pdf

Sharing code snippets below, some names have been changed and partial code is added.

/* code snippets starts */

/* function 1 */
function check_doc {
// exts to place in /docs folder with file_extension as param
$doc_types_string = str_replace(' ', '', get_site_option('document-types'));
$doc_types = explode(',', $doc_types_string);
$file_extension = pathinfo($filename, PATHINFO_EXTENSION);
return in_array($file_extension, $doc_types);
}

/* function 2 */
function a_upload_filter($file)
{
if (is_convera_doc($file['name'])) {
add_filter('upload_dir', 'field_name_upload_dir');
}
return $file;
}
add_filter('wp_handle_upload_prefilter', 'a_upload_filter');

/* function 3 code snippet - */
$uploads['baseurl'] = site_url();
$uploads['basedir'] = get_home_path();
$uploads['path'] = $uploads['basedir'] . 'docs';
$uploads['url'] = $uploads['baseurl'] . '/docs';
$uploads['subdir'] = '';

return $uploads;

/* snippet ends */

Let me know if you need more information.

Thanks

July 9, 2026 at 5:53 am #18148364

Dražen
Supporter

Hello,

Thank you for providing the additional details and the code snippets.

Based on our support policy, we aren't able to debug or provide support for custom code, as this falls outside the scope of WPML support.

- https://wpml.org/purchase/support-policy/

That said, I'd still be happy to take a quick look and see if I can spot anything obvious or suggest a possible workaround. Since this involves custom functionality, I can't guarantee that I'll be able to identify the cause or provide a solution.

The easiest way for me to check this would be if you could reproduce the issue in a simple test site with only the relevant custom code and the minimum steps needed to reproduce the problem. That would allow me to quickly verify whether this is something related to WPML's language handling or whether the custom code needs to be adjusted to work in a multilingual setup.

From the snippets you've shared, I can't reliably determine whether the issue is in the custom upload path logic itself or how the URLs are being generated on translated pages. Having a minimal reproducible example would make it much easier to investigate.

Please go to next sandbox test site and try to reproduce simple example issue:

- hidden link

Kind regards,
Dražen

July 14, 2026 at 2:30 pm #18157654

Atul Shinh

Hi Drazen,

On our end we tried something else which gave some positive output. It was found that PDF files having path issue on translated languages have media translation available. When I deleted the media translation, by deleting the media file from translated language and re-checking the link on translated website blog post, the file path was fixed.

Issue is that the file itself got deleted although it was still showing in MEDIA for source EN language. I think deleting media translation could help us but can you please confirm the right way to delete a media translation?

Thanks

July 15, 2026 at 5:31 am #18158564

Dražen
Supporter

Hi,

You can delete only the translated media item from the Media Library while viewing the translated language.

Let me know if that helps.

Kind regards,
Dražen

July 15, 2026 at 7:02 pm #18160462

Atul Shinh

Hi Drazen,

The issue was resolved by deleting media translation for media document from translated languages.

The only issue faced was that original media document was 404 after the process although in backend (Media > Library), in source language the original document record was present.

The document were restored on server by replacing with backup of document made before process.

Is this normal or related to some settings in WPML settings?

Apart from this question there is nothing else. Ticket can be closed with the response from your side.

Many thanks for your support.

July 16, 2026 at 6:10 am #18160937

Dražen
Supporter

Hi,

I'm glad to hear the issue was resolved.

Regarding the original media document returning a 404, WPML should not affect the default language media URL, so as far as I'm know, this should not be expected behavior or caused by a WPML setting.

Since there are no further questions, I'll go ahead and close this ticket. If you need any further assistance in the future, please don't hesitate to open a new ticket or contact us again.

Kind regards,
Dražen