Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 13:00 9:00 – 13:00 9:00 – 13:00 8:00 – 12:00 8:00 – 12:00 -
- 14:00 – 17:00 14:00 – 18:00 14:00 – 18:00 13:00 – 17:00 13:00 – 17:00 -

Supporter timezone: Europe/Zagreb (GMT+02:00)

This topic contains 5 replies, has 2 voices.

Last updated by Bruno Kos 1 year, 10 months ago.

Assisted by: Bruno Kos.

Author Posts
June 23, 2022 at 4:33 pm #11532019

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.

June 27, 2022 at 7:06 am #11547073

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

June 27, 2022 at 1:15 pm #11551527

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

June 30, 2022 at 1:06 pm #11576613

zenC

The workaround did work out for me! Thank you!

June 30, 2022 at 2:49 pm #11578197

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.

July 1, 2022 at 6:43 am #11582335

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+02:00)

Escalated to WPML developers team.