Background of the issue:
I am trying to translate a blog post using the classic editor view and the normal flow (ATE). In the original version, images have a 'link to media file.'
Symptoms:
After translation, the image links change to 'custom link,' causing only the thumbnail to open in the lightbox instead of the full-size image. Manually changing it back to 'link to media file' resolves the issue.
Questions:
Why do image links change from 'link to media file' to 'custom link' after translation?
How can I ensure that image links remain as 'link to media file' during translation?
Christopher is currently unavailable. I have confirmed that the issue has been reported, but there are no updates at this time. We will update you here as soon as more information is available.
Would you please update WPML to version 4.7.3 and also update WPML String translation? Then please cehck by adding a new media and see if the issue is still there or not.
We have found that the problem might occur when there are some characters used in the image names that are like spaces but not actual space. For example the Mac devices create images when using the screenshot tool with that format.
WordPress do not replace such characters to hyphens and that was the problem cause.
If you want to avoid such scenarios you can use the code below which you can add to your functions.php file of your theme:
/**
* Normalise ALL Unicode space-separator characters to a dash.
*
*/
add_filter( 'sanitize_file_name', 'wpmlsupp_normalise_unicode_spaces', 5, 2 );
function wpmlsupp_normalise_unicode_spaces( $sanitised, $raw_filename ) {
// Collapse every Unicode *space separator* (general-category Zs) to a single dash
// Examples caught here: U+00A0 (NO-BREAK SPACE), U+202F (NARROW NBSP), U+2009 (THIN SPACE), etc.
$raw_filename = preg_replace( '/\p{Zs}+/u', '-', $raw_filename );
return $raw_filename;
}
The code above will not fix the issue for the current images but for future uploads. But the best way is to avoid using any special characters in your images.
But there are no breaks or spaces in the file names. The file name structure is always the same, containing only lowercase letters, numbers, and the characters “-” and “_”.