- 상태
- 해결됨
- 보고된 제품
- WPML Media Translation 2.7.4
- 해결된 버전
- WPML 4.7.2
- 주제 태그
- Bug
문제 개요
WPML 미디어 번역 플러그인을 사용하는 경우, 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; }