- Status
- Waiting for author
- Related plugin/theme
- WP Offload Media
- Topic tags
- Compatibility
Overview of the issue
When you use WP Offload Media together with WPML Media Translation, replacing a translated image may generate an incorrect S3 file path. This issue occurs when a translated image is replaced after the original translation was uploaded in a different month or year.
Workaround
Please, make sure of having a full site backup of your site before proceeding.
Option 1
Go to the Media Library, use the “Remove from Bucket” option and manually replace it with a new image.
Option 2
Alternatively, you can try the following but you may end with orphaned objects in the bucket:
- 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(); } }