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
- 9:00 – 14:00 9:00 – 14:00 9:00 – 14:00 9:00 – 14:00 9:00 – 14:00 -
- 15:00 – 18:00 15:00 – 18:00 15:00 – 18:00 15:00 – 18:00 15:00 – 18:00 -

Supporter timezone: Asia/Dhaka (GMT+06:00)

This topic contains 3 replies, has 2 voices.

Last updated by Prosenjit Barman 1 year, 1 month ago.

Assisted by: Prosenjit Barman.

Author Posts
April 15, 2024 at 2:13 pm #15520657

matthewS-46

I have a logo added from an ACF Options page that is shown from header.php. This image will not show on translated pages and no src is in the IMG tag.

Images used in other ACF field groups show on all pages.

Image shown with this code
<img src="<?php echo $main_logo['url']; ?>" alt="<?php echo get_bloginfo('name'); ?>" />

April 16, 2024 at 4:28 am #15522255

Prosenjit Barman
WPML Supporter since 03/2023

Languages: English (English )

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

Hello There,
Thanks for contacting WPML Support.

I understand the issue you're having. Based on the code you shared, the image URL should appear in the source attribute of the image tag. However, if the ACF field is configured to return an ID instead of a URL, the code snippet you're using might not retrieve the URL correctly, leading to the image not displaying. Please check your field settings to ensure that the Return format is set to "URL". After adjusting this setting, you may need to update your code accordingly. For guidance on how to adjust the code, please refer to the example provided in the following link: hidden link

If the above steps don’t resolve the issue, set the 'Return Format' for the image field to 'image array' and try debugging directly in your `header.php` file. Temporarily replace your current image code with the following PHP code snippet to test if the image URL is being retrieved:

<?php $main_logo = get_field('logo_field_name', 'option'); // Replace 'logo_field_name' with your actual field name
if ($main_logo) {
    echo '<img src="' . esc_url($main_logo['url']) . '" alt="' . esc_attr(get_bloginfo('name')) . '">';
} else {
    echo 'Logo not found'; // Debug message if logo is not found
}
?>

This will help confirm whether the image URL is being fetched correctly. If 'Logo not found' appears, then the issue might be with how the image is being saved or retrieved.

[Just a heads up, providing support for custom coding falls outside the scope of our standard support services. The code shared above is intended as an example to help you debug the issue. If you require assistance with custom coding, I recommend hiring a developer or a professional who specializes in customizing ACF and ACFML. You can find qualified contractors through this link: https://wpml.org/contractors/.&#093;

Additionally, since the Media Translation plugin is active on your site, you can also check by translating the image by following the guidelines mentioned here: https://wpml.org/documentation/getting-started-guide/media-translation/

Let me know if the information above helps or if you need further assistance. I will be happy to help.

Best regards,
Prosenjit

April 16, 2024 at 11:21 am #15524569

matthewS-46

I have tried serving the image as an array and just as a URL and neither work, no SRC is served on translated pages, fine on the original English page so the code can't be wrong.

This only seems to apply from images added via an ACF image field on an ACF generated options page. The images I have added using ACF image fields within custom Gutenberg blocks are being served correctly on the original and the translated pages.

The image I am trying to show is a SVG logo but again, I am showing other SVG icons via ACF image fields and they work on everything.

I know custom coding falls outside your remit but my code works for the non-translated page so there is nothing wrong with the code or the way the image is being saved.

April 17, 2024 at 4:35 am #15529001

Prosenjit Barman
WPML Supporter since 03/2023

Languages: English (English )

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

Hi There,
Thank you for the update.

As the issue persists, a closer inspection will be required to understand the root cause of the issue.

I would like to request temporary access (wp-admin and FTP) to your site to take a better look at the issue. It would be better to have a testing site where the issue is replicated.

You will find the needed fields below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.

Maybe I'll need to replicate your site locally. For this, I’ll need to temporarily install a plugin called “Duplicator” or "All in One WP Migration" on your site. This will allow me to create a copy of your site and your content. Once the problem is resolved I will delete the local site. Let me know if this is ok with you.

IMPORTANT
-Please backup site files and database before providing us access.
-If you do not see the wp-admin/FTP fields this means your post & website login details will be made PUBLIC. DO NOT post your website details unless you see the required wp-admin/FTP fields. If you do not, please ask me to enable the private box. The private box looks like this:
hidden link

Looking forward to your response.

Best Regards,
Prosenjit

The topic ‘[Closed] Image in header PHP file from ACF Options page not showing in translations’ is closed to new replies.