- Status
- Resolvido
- Relatado para
- WPML Media Translation 2.7.4
- Resolvido em
- WPML 4.7.2
- Tags de tópico
- Bug
Visão geral do problema
Se você estiver usando o plugin WPML Media Translation, poderá encontrar um problema quando uma imagem muito grande que aciona o redimensionamento do WordPress é traduzida e, em seguida, uma das traduções é removida. Como resultado, o arquivo da imagem original também é excluído e haveria um link de imagem quebrado no idioma original.
Solução alternativa
Por favor, certifique-se de ter um backup completo do seu site antes de prosseguir.
- Abra o arquivo …/wp-content/plugins/sitepress-multilingual-cms/classes/media/class-wpml-attachment-action.php.
- Procure a linha 171.
- Substitua:
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; } - Por:
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; }