WPML
สถานะ
แก้ไขแล้ว
รายงานสำหรับ
WPML Media Translation 2.7.4
แก้ไขใน
WPML 4.7.2
แท็กหัวข้อ
Bug

ภาพรวมของปัญหา

หากคุณกำลังใช้ปลั๊กอิน WPML Media Translation คุณอาจพบปัญหาเมื่อรูปภาพที่มีขนาดใหญ่เกินไปซึ่งทำให้เกิดการปรับขนาดของ WordPress ได้รับการแปล แล้วการแปลรายการใดรายการหนึ่งถูกลบออก ส่งผลให้ไฟล์รูปภาพต้นฉบับถูกลบไปด้วย และจะมีลิงก์รูปภาพเสียในภาษาต้นฉบับ

วิธีแก้ปัญหาชั่วคราว

โปรดตรวจสอบให้แน่ใจว่าคุณได้สำรองข้อมูลเว็บไซต์ทั้งหมดก่อนดำเนินการต่อ


  • เปิดไฟล์ …/wp-content/plugins/sitepress-multilingual-cms/classes/media/class-wpml-attachment-action.php

  • ค้นหาบรรทัดที่ 171

  • แทนที่:
    	public function delete_file_filter( $file ) {
    		if ( $file ) {
    			$file_name           = $this->get_file_name( $file );
    			$sql                 = "SELECT pm.meta_id, pm.post_id FROM {$this->wpdb->postmeta} AS pm
    						WHERE pm.meta_value = %s AND pm.meta_key='_wp_attached_file'";
    			$attachment_prepared = $this->wpdb->prepare( $sql, [ $file_name ] );
    			$attachment          = $this->wpdb->get_row( $attachment_prepared );
    
    			if ( ! empty( $attachment ) ) {
    				$file = null;
    			}
    		}
    
    		return $file;
    	}

  • ด้วย:
    	public function delete_file_filter( $file ) {
    		if ( $file ) {
    			$file_name           = $this->get_file_name( $file );
    			$test = explode('.', $file_name);
    			$sliced = array_slice($test, 0, -1);
    			$scaled = implode('.', $sliced);
    			$ext = '-scaled.'. end($test);
    			$processed = $scaled.$ext;
    
    			$sql                 = "SELECT pm.meta_id, pm.post_id FROM {$this->wpdb->postmeta} AS pm 
    						WHERE pm.meta_value = %s OR pm.meta_value = '$processed' AND pm.meta_key='_wp_attached_file'";
    			$attachment_prepared = $this->wpdb->prepare( $sql, [ $file_name ] );
    			$attachment          = $this->wpdb->get_row( $attachment_prepared );
    
    			if ( ! empty( $attachment ) ) {
    				$file = null;
    			}
    		}
    
    		return $file;
    	}

ปัญหาที่ทราบแล้วทั้งหมด →