Chuyển đến nội dung Chuyển đến thanh bên

Waiting for author

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();
    		}
    	}
    

Để lại trả lời

Vui lòng giữ đúng chủ đề và tôn trọng người khác. Nếu bạn cần trợ giúp với các vấn đề không liên quan đến bài đăng này, hãy sử dụng Diễn đàn Hỗ trợ của chúng tôi để bắt đầu trò chuyện hoặc gửi vé hỗ trợ.

Bạn có thể sử dụng các thẻ này:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>