- Trạng thái
- Đã giải quyết
- Được báo cáo cho
- WPML Media Translation 2.7.4
- Đã giải quyết trong
- WPML 4.7.2
- Thẻ chủ đề
- Bug
Tổng quan về lỗi
Nếu bạn đang sử dụng plugin WPML Media Translation, bạn có thể gặp sự cố khi một hình ảnh quá khổ kích hoạt tính năng thu phóng của WordPress được dịch và sau đó một trong các bản dịch bị xóa. Do đó, tệp hình ảnh gốc cũng bị xóa và sẽ có một liên kết hình ảnh bị hỏng trong ngôn ngữ gốc.
Giải pháp tạm thời
Vui lòng đảm bảo có bản sao lưu toàn bộ trang web trước khi tiếp tục.
- Mở tệp …/wp-content/plugins/sitepress-multilingual-cms/classes/media/class-wpml-attachment-action.php.
- Tìm dòng 171.
- Thay thế:
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; } - Bằng:
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; }