- Estado
- Resuelto
- Notificado para
- WPML Media Translation 2.7.4
- Resuelto en
- WPML 4.7.2
- Etiquetas de temática
- Bug
Resumen del problema
Si está utilizando el plugin WPML Media Translation, puede encontrar un problema cuando se traduce una imagen de gran tamaño que activa el escalado de WordPress y luego se elimina una de las traducciones. Como resultado, el archivo de imagen original también se elimina y habría un enlace de imagen roto en el idioma original.
Solución alternativa
Por favor, asegúrese de tener una copia de seguridad completa de su sitio antes de continuar.
- Abra el archivo …/wp-content/plugins/sitepress-multilingual-cms/classes/media/class-wpml-attachment-action.php.
- Busque la línea 171.
- Reemplace:
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; }