zenC
I'm trying to delete wpml but experience trouble doing so.
I delete all the plugins and noticed that the images in the media library are shown twice now. So I reinstalled the plugins switched to the foreign language and started deleting the doubled images. Which works fine except when the image is rescaled by WordPress (name ends in "-scaled") then deleting results in the original image and all smaller versions(300x300, 100x100) being deleted. Only the scaled version is kept.
Bruno Kos
Supporter
Languages:
English (English )
German (Deutsch )
French (Français )
Timezone:
Europe/Zagreb (GMT+02:00)
Hi,
This is escalated to our 2nd tier team and may take some debugging time, I'll get back to you as soon as I have any news or questions for you.
Regards,
Bruno Kos
Bruno Kos
Supporter
Languages:
English (English )
German (Deutsch )
French (Français )
Timezone:
Europe/Zagreb (GMT+02:00)
Hi,
This issue has been escalated to WPML developers.
I will keep this thread updated as soon as I get any new information from them!
As a workaround, in wp-content/plugins/sitepress-multilingual-cms/classes/media/class-wpml-attachment-action.php on the line 171 where it says:
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;
}
replace with:
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;
}
Regards,
Bruno Kos
zenC
The workaround did work out for me! Thank you!
zenC
I think I will keep the thread open until, the issue is fixed in the most recent version.
So other people encountering the problem, see when it is fixed.
Bruno Kos
Supporter
Languages:
English (English )
German (Deutsch )
French (Français )
Timezone:
Europe/Zagreb (GMT+02:00)
Escalated to WPML developers team.