Skip to content Skip to sidebar

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.

This topic contains 9 replies, has 2 voices.

Last updated by Prosenjit Barman 1 year, 9 months ago.

Assisted by: Prosenjit Barman.

Author Posts
October 3, 2023 at 6:57 pm #14508251

garyB-6

This is a new problem that started today, images won't load on the translated pages, and a broken image icon loads. See hidden link and you will see the logo at the top of the page load and on the french and spanish a broken image link shows

October 4, 2023 at 9:18 am #14511079

Prosenjit Barman
WPML Supporter since 03/2023

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

Hello There,
Thank you for contacting WPML Support.

I checked the French and Spanish versions of the site and understood the issue. Upon checking, I found that the folders where the image is stored are not getting loaded and instead, a double slash is showing in the file path. This is why, the image is not showing properly. Please check this screenshot: hidden link

We previously had a similar issue where the issue was caused due to manually defining the upload folder in the wp-config.php. If you also have made the same adjustments, Could you please try following the suggestion mentioned in the ticket below?

- https://wpml.org/forums/topic/image-url-contains-a-double-slash/#post-11164589

If your case is different, then kindly follow the steps mentioned below and check if that helps to solve the issue.

- Take a full backup of your site.
- Access the root folder of your site using the FTP tool or from the file directory of your server.
- locate the ".htaccess" file and edit it.
- Copy the rules added there and save it on a notepad.
- Replace the htaccess rules with the one included here: https://wordpress.org/documentation/article/htaccess/#basic-wp
- Save the changes.
- Open the default post with the SVG image.
- Remove the image and add it again.
- Save the changes and update the translation as well.

Please let me know how it goes. I will be happy to help if you need further assistance in this matter.

Best Regards,
Prosenjit

October 5, 2023 at 2:17 pm #14521063

garyB-6

Hi Prosenjit,

I have not changed the wp.config as you can see below.

This has only started happening when I try to update a page as well as with new posts.

On the home page, our corporate brand has been the same for years and displayed properly. I added a new section below the fold and after saving the updates the logo dropped and some images in the new section don't display in French or Spanish.

Even more frustrating is some images do load and others won't.

Any other suggestions?

[Information Removed]

October 5, 2023 at 5:19 pm #14522485

garyB-6

I see the same thing you do, that the path is hidden link and the other languages are pointing to hidden link which is missing date between the // and therefore can not load. My question is why and how do I rectify this? I have placed the image and saved it. WPML shows the needs update icon (refresh symbol) and I have done the update. I am no further ahead yet.

Please advise.

Thanks,

GB

October 6, 2023 at 7:56 am #14524815

Prosenjit Barman
WPML Supporter since 03/2023

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

Hello GB,
Thank you for sharing the information. For security purposes, I had to delete the config and access info from the response.

Upon rechecking the WPML Debug information, I noticed that both the 'SVG Support' and 'WPML Media Translation' plugins are active on your website.

We recently found that when the SVG Support plugin is activated alongside the WPML Media Translation plugin, it results in an incomplete SVG image URL. As a result, the SVG doesn't display on the frontend. Fortunately, Our development team has found a workaround for this problem.

Since the issue you're having is close to the issue we've identified, could you please try the workaround detailed in the Errata below and see if it solves the problem?

- https://wpml.org/errata/svg-support-activating-wpml-media-strips-uploads-folders-from-svg-image-url/

Let me know if that helps or if you need further assistance. I will be happy to assist.

Best regards,
Prosenjit

October 6, 2023 at 2:21 pm #14529213

garyB-6

The workaround produced the following error:

Warning: preg_match(): Unknown modifier 'd' in /home/customer/www/staging2.solarcsystems.ca/public_html/wp-content/themes/divi-master/functions.php on line 88

In addition, we have two identical sites, com and a .ca domian for different market segments and the .com does not have this problem. I have checked that configurations for plugins, function.php, caching etc are the same from one site to the other. You can see this by going to hidden link and then to solarcsystems.ca - the brand logo at the top functions properly on the .com domain and not on the .ca

Do you have any other ideas that might resolve this?

Thanks,

GB

October 6, 2023 at 3:50 pm #14530153

garyB-6

This is what is on line 88:
if (isset($data['file']) && !preg_match('/d{4}/d{2}//', $data['file'])) {

October 9, 2023 at 3:51 am #14535751

Prosenjit Barman
WPML Supporter since 03/2023

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

Hi GB,
I hope you're doing well. Sorry for the delay in responding due to the weekend.

The warning typically arises for not formatting the regular expression correctly. Within the preg_match() function, there's a double slash (//) after d{2}. That delimiter should be escaped with a backslash. It should look like this: '/d{2}\/\/'.

However, I have checked your site(.ca domain) and now I can see that the Logo is loading properly in the French and Spanish versions of the site. Please check this video for a better understanding: hidden link

I hope the workaround helps to fix the issue. Since the images are showing fine in other languages, I think it is safe to ignore that warning. But, feel free to let me know if you need any further assistance. I will be happy to help.

Best Regards,
Prosenjit

October 10, 2023 at 5:46 pm #14553153

garyB-6

Hi Prosenjit,

The issue isn't resolved. Yes, I got the brand logos to appear however the problem still exists. For instance, if scroll down to the "What can help with" section you will see four images describing different medical conditions that won't load on the FR or ES languages.

I am hoping your code can resolve this by including the full code I used from your site, can you please send me the corrected version in it's totality.

Here it is:

// WPML Workaround for compsupp-6933
add_filter('wp_get_attachment_metadata', 'wpml_compsupp6933_fix_attachment_metadata_file_path', 10, 2);

function wpml_compsupp6933_fix_attachment_metadata_file_path($data, $attachment_id) {

// Only apply the workaround if WPML Media and SVG Support plugins are active
if( class_exists('WPML_Media') && function_exists('bodhi_svgs_generate_svg_attachment_metadata') ) {

if (isset($data['file']) && !preg_match('/d{4}/d{2}//', $data['file'])) {
// Get the upload directory info
$upload_dir_info = wp_upload_dir();

// Extract the year and month from the basedir
$year_month = date('Y/m', strtotime(get_post_field('post_date', $attachment_id)));

// Prepend the year and month to the file
$data['file'] = $year_month . '/' . $data['file'];

}
}

return $data;
}

Screenshot 2023-10-10 134548.png
Screenshot 2023-10-10 134457.png
October 11, 2023 at 9:07 am #14557281

Prosenjit Barman
WPML Supporter since 03/2023

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

Hi There,

I've reviewed both the French and Spanish versions of the site and identified the issue. Below, you'll find the updated code. Kindly insert this code into the functions.php file of your theme and then try the steps mentioned below.

// WPML Workaround for compsupp-6933
add_filter('wp_get_attachment_metadata', 'wpml_compsupp6933_fix_attachment_metadata_file_path', 10, 2);

function wpml_compsupp6933_fix_attachment_metadata_file_path($data, $attachment_id) {

	// Only apply the workaround if WPML Media and SVG Support plugins are active
	if( class_exists('WPML_Media') && function_exists('bodhi_svgs_generate_svg_attachment_metadata') ) {
		
		if (isset($data['file']) && !preg_match('/\d{4}\/\d{2}\//', $data['file'])) {
			// Get the upload directory info
			$upload_dir_info = wp_upload_dir();
	
			// Extract the year and month from the basedir
			$year_month = date('Y/m', strtotime(get_post_field('post_date', $attachment_id)));
	
			// Prepend the year and month to the file
			$data['file'] = $year_month . '/' . $data['file'];
			
		}
	}    

    return $data;
}

- After adding the code, open the main page in the editor
- Remove the images from the 'What Can We Help You With?' section and add them again.
- Make any small change in the text
- Save the changes and complete the translation update.

I hope the issue will be solved after that. Please let me know if you still need any further assistance. I will be happy to help.

Best regards,
Prosenjit