- Stato
- Risolto
- Segnalato per
- WPML Media Translation 2.7.4
- Risolto in
- WPML 4.7.2
- Tag dell’argomento
- Bug
Panoramica del problema
Se stai usando il plugin WPML Media Translation, potresti riscontrare un problema quando un’immagine sovradimensionata che attiva il ridimensionamento di WordPress viene tradotta e poi una delle traduzioni viene rimossa. Di conseguenza, anche il file dell’immagine originale viene eliminato e ci sarebbe un link all’immagine interrotto nella lingua originale.
Soluzione alternativa
Assicurati di avere un backup completo del sito prima di procedere.
- Apri il file …/wp-content/plugins/sitepress-multilingual-cms/classes/media/class-wpml-attachment-action.php.
- Cerca la riga 171.
- Sostituisci:
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; } - Con:
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; }