WIP: WPML Media to put a different svg for each language

Hello,
I talk with WPML team and there is a bug between the feature “enable svg” from Bricks and WPML Media to put different image per language. As you can see when we use WPML Media to put a different svg for each language, it doesn’t work as you can see on my short recording that I made for you : WPML SVG Media translation.mp4 - Google Drive
It seems it doesn’t store the data.

We temporary solved it with this code

  • Open the /wp-content/themes/bricks/includes/integrations/wpml/wpml.php file.
  • Look for line 509.
  • Replace:
public function get_translated_attachment_id( $attachment_id ) {
    return apply_filters( 'wpml_object_id', $attachment_id, 'attachment', true );
}
  • With:
public function get_translated_attachment_id( $attachment_id ) {
    if ( is_admin() && did_action( 'admin_init' ) ){
        $current_screen = get_current_screen();
     }
 
    // Check if the current screen is the WPML Media Translation screen (you'll need the exact screen ID)
    if ( $current_screen && $current_screen->id === 'wpml_page_wpml-media' ) {
        return $attachment_id; // Return the original image if it's a WPML Media Translation screen.
    }       
 
    return apply_filters( 'wpml_object_id', $attachment_id, 'attachment', true );
}

Now, I can upload different svg in Media translation per language but it won’t work with svg widget to display translated svg, it only works if we put the svg in a image widget.

Greetings,

The WPML team offers me the following workaround for SVG widget:

Remember to take theme’s backup beforehand.

  • Open …/wp-content/themes/bricks/includes/elements/svg.php file.
  • Look for line 134.
  • Change:
$svg_path = get_attached_file( $this->settings['file']['id'] );
  • For:
$svg_path = get_attached_file( apply_filters( 'wpml_object_id', $this->settings['file']['id'], 'attachment', FALSE ) );

Hi @creativeart,

Thank you for reporting this. I was able to replicate it and have added this to our internal bug tracker.

1 Like

Do you know when this bug will be corrected ?

Hi @creativeart,

We’re unable to provide ETAs or specific timeframes for bug resolutions.