Skip to content Skip to sidebar

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

Problem:
The client reported an issue with media translation paths when replacing an image uploaded in the same month as the original. This problem was specific to their setup and involved the Offload Media plugin.
Solution:
We suggested a workaround involving code changes in the Offload Media plugin. Specifically, the client needed to open

.../amazon-s3-and-cloudfront-pro/classes/pro/integrations/wpml.php

and replace the existing setup function with:

public function setup() {<br />    add_action( 'wpml_media_create_duplicate_attachment', array( $this, 'duplicate_offloaded_item' ), 10, 2 );<br />    add_action( 'wpml_updated_attached_file', array( $this, 'delete_offloaded_item_on_media_replace' ), 10, 3 );<br />}<br /><br />public function delete_offloaded_item_on_media_replace( $attachment_id, $file, $language ) {<br />    $as3cf_item = Media_Library_Item::get_by_source_id( $attachment_id );<br /><br />    if ( $as3cf_item ) {<br />        $as3cf_item->delete();<br />    }<br />}

We also communicated with the plugin authors to seek a permanent fix. Meanwhile, the client can use this workaround as a temporary solution.

Please note that this solution might be 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 the issue persists, please open a new support ticket 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 16 replies, has 0 voices.

Last updated by T4ng 1 day, 9 hours ago.

Assisted by: Dražen.

Author Posts
May 4, 2026 at 8:07 am #18010067

T4ng

Follow up on that ticket, which is closed
https://wpml.org/forums/topic/wrong-media-translation-path/

I've been able to reproduce the issue from the sandbox: hidden link
Screencast (I can only upload images here...): hidden link

Let's discuss it again @Dražen

Thanks

May 4, 2026 at 8:49 am #18010182

Dražen
Supporter

Languages: English (English )

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

Hello,

thank you for the follow-up and for sharing the sandbox and video.

I checked the screencast and the sandbox site. I can see the broken image URL for the image you pointed out, however the video cuts off at that point and the page remains blank, so I’m not able to clearly follow the exact steps that lead to the issue.

I also tried uploading and using new "translated" images in the Media Library on the sandbox, and those URLs are generated correctly on my end.

Could you please check and share the exact step-by-step process to reproduce the issue (or a longer video showing the full flow)? That would help me investigate this further.

Regards,
Dražen

May 4, 2026 at 2:34 pm #18011304

T4ng

Hi.

Indeed, my bad, the video is the wrong one, and obviouly I had an issue while recording the right upload attempt.

The issue occurs when I try to replace an image translation that's been updated on on different year/month.
The image you see as broken is the one I replaced (though I think you replaced it again in the meantime.

All I did today was replacing this image by another one from the Media translation screen. The newly uplodaed image will show up as broken, because once updated, the filename is fine, but the path is the one from the previous image (or the original image, I'm not so sure): 2026/04/

Disable Offload Media, the image will show up, because the path of the uploaded translation image is now fine: it reflects todays' date: 2026/05/

Please test it.

May 4, 2026 at 2:49 pm #18011318

T4ng

By the way, I think your website faces caching issues.
The message I posted 15 minutes still wouldn't show up after clean page refresh, and the post notification setting apparently wouldn't save, or show up as saved, until a few more minutes.
Finally, after a few more minutes, my message has shown up, and the notifications settings got saved (or appeared as).

May 5, 2026 at 6:29 am #18012442

Dražen
Supporter

Languages: English (English )

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

Hello,

thanks for the patience and your replies.

I have escalated this further to our compatibility team.

I will update here when I have some news.

Regards,
Drazen

May 6, 2026 at 5:15 am #18015722

Dražen
Supporter

Languages: English (English )

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

Hello,

our team will check further but it does seem that the WPML integration is included as part of their Premium license.

Because of this, the plugin authors should also be able to assist with compatibility and integration-related issues from their side.

We will still take a closer look from the WPML side , but to speed things up I would also recommend contacting their support in parallel, as they may already know about the issue or have a workaround available.

Thank you.
Drazen

May 6, 2026 at 7:37 am #18015975

T4ng

Hi.

"Our team will check further but it does seem that the WPML integration is included as part of their Premium license."

I have opened a ticket with Delicious Brains about the issue.

Can you please extend the sandbox's lifetime again, so that it doesn't disappear before they can take a look?

Best Regards.

May 6, 2026 at 12:05 pm #18017351

Dražen
Supporter

Languages: English (English )

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

Hello,

thanks, yes, I have extended it and the sandbox will now be available until July.

Regards,
Drazen

May 7, 2026 at 5:44 am #18018922

Dražen
Supporter

Languages: English (English )

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

Hello,

we are still trying to reproduce the issue, but so far it seems to work correctly for other images, even when they are uploaded in different months.

For example, if you check Media Translation now, you will see I replaced several images and they are showing correctly without issues.

- hidden link

At the moment, we are unable to reproduce the same behavior. It currently only seems to happen with the specific image you replaced, so we are a bit stuck from the debugging side because other images work as expected.

Can you please check and advise further if we are missing some steps?

Regards,
Drazen

May 7, 2026 at 8:28 am #18019506

T4ng

The issue occurs when replacing an alternative image that was already uploaded the same month as the original image was uploaded.

May 7, 2026 at 9:01 am #18019721

T4ng

My tests were explained in details here:
https://wpml.org/forums/topic/wrong-media-translation-path/page/2/#post-17943431

May 7, 2026 at 9:28 am #18019784

Dražen
Supporter

Languages: English (English )

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

Hello,

Thanks, I missed that, apologies. We have been going back and forth on this issue for quite a while now, so some things got lost.

I will continue checking based on that specific scenario and share with our 2nd tier further.

Regards,
Drazen

May 11, 2026 at 5:52 am #18025701

Dražen
Supporter

Languages: English (English )

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

Hello,

we checked, and as the workaround please do next:

Open .../amazon-s3-and-cloudfront-pro/classes/pro/integrations/wpml.php

Replace:

	public function setup() {
		add_action( 'wpml_media_create_duplicate_attachment', array( $this, 'duplicate_offloaded_item' ), 10, 2 );
	}

With:

public function setup() {
		add_action( 'wpml_media_create_duplicate_attachment', array( $this, 'duplicate_offloaded_item' ), 10, 2 );
		add_action( 'wpml_updated_attached_file', array( $this, 'delete_offloaded_item_on_media_replace' ), 10, 3 );
	}

	public function delete_offloaded_item_on_media_replace( $attachment_id, $file, $language ) {
		$as3cf_item = Media_Library_Item::get_by_source_id( $attachment_id );

		if ( $as3cf_item ) {
			$as3cf_item->delete();
		}
	}

Please also share this with plugin authors, and we will also contact them, as this needs to be fixed from their side.

Kind regards,
Drazen

May 11, 2026 at 7:27 am #18025986

T4ng

Hi,
That's good news.

Can we test in on the sandbox?

If it works, once the patch is applied, I should be able to replace the broken image.

I shared this with Offload Media. There's a ticket going on.

May 11, 2026 at 10:15 am #18026856

T4ng

Answer from the developers:

"Unfortunately we could not use that solution as is, as it’ll leave orphaned objects in the bucket, but it is good to know about the wpml_updated_attached_file filter, I expect we can use that."