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 thread is resolved. Here is a description of the problem and solution.

Problem: Acf images not displaying on the front end

Solution: The client found a relevant thread and solved the issue https://wpml.org/forums/topic/acf-image-field-returns-an-array-on-regular-page-and-an-id-on-translated-page/ 1) set the _img system field for that custom post and updated the page. 2) batch duplicated all the posts for that custom type.

This topic contains 4 replies, has 2 voices.

Last updated by Matteo 3 months, 2 weeks ago.

Assigned support staff: Raja Mohammed.

Author Posts
July 2, 2019 at 10:14 am #4125603

Matteo

I am trying to: translate a website in Chinese.

Link to a page where the issue can be seen: hidden link

I expected to see: the duplicated media thumbnail for each Lecturer

Instead, I got: some thumbnails and some broken Urls.

Please note that:
1) I added a new language (zh-hant)
2) I duplicated the media from WPML -> Settings
3) I duplicated the ACF fields
4) I fixed the unassigned settings for ACF fields, assigning "Copy" to image fields
5) I duplicated the lecturers' entries.

Images are, as expected, linked to the translated entry but then they are not randomly showed on the page.

Also note that if I open the record for a lecturer and then I update it, the image shows up.
Unfortunately I should do that for 200 entries.
Why did it happen?
Is there a way to fix this?
Thank you in advance for your help/support.

July 2, 2019 at 1:06 pm #4127223

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi,

I will help you with your issue.

Before proceeding further in investigating the issue, Please update the WPML and ACF Multilingual to the latest version. We have fixed a few issues relates to images in the latest version ACF Multilingual plugin.

please backup your site and database before proceeding with the update.

Once the plugin is updated check if the issue can be reproduced, Also try updating the original post and translation in case the update didn't help.

Please let me know the results

Kind regards
Raja

July 2, 2019 at 2:16 pm #4127885

Matteo

Hi Raja,
Thank you for reaching me.
I updated all the WPML plugins to the last version.
Issue is still in place.

Please note that I clearly wrote that by updating the Lecturer's custom post, the issue solves. I'm just looking for a bulk solution as there are hundreds of entries.

Currently, in production I'm getting:

<img src="<br />
<b>Warning</b>:  Illegal string offset 'sizes' in <b>/home/rafflesmilano/rm-modaedesign/wp-content/themes/rm-modaedesign/_partials/section__fc-people-grid.php</b> on line <b>21</b><br />
<br />
<b>Warning</b>:  Illegal string offset 'squared-800' in <b>/home/rafflesmilano/rm-modaedesign/wp-content/themes/rm-modaedesign/_partials/section__fc-people-grid.php</b> on line <b>21</b><br />
1" alt="<br />
<b>Warning</b>:  Illegal string offset 'alt' in <b>/home/rafflesmilano/rm-modaedesign/wp-content/themes/rm-modaedesign/_partials/section__fc-people-grid.php</b> on line <b>21</b><br />
1" style="width: 100%;">

while in my local environment I'm just getting:

<img src="1" alt="1" style="width: 100%;">

PHP code is:

<?php $img = get_field( 'img' ); ?>
						<?php if ( $img ) { ?>
							<div class="img"><img src="<?php echo $img['sizes']['squared-400']; ?>" alt="<?php echo $img['alt']; ?>" style="width: 100%;"/>
								<div class="hover">
									<div class="quote"><?php the_field( 'quote' ); ?></div>
								</div>
							</div>
						<?php } ?>

ACF image field is set to return an Array.

Functions.php contains "add_image_size()" instructions for all needed sizes.

July 2, 2019 at 2:35 pm #4127971

Matteo

Update: As far as I can see, for some reasons, some images are returned as ID rather than as Array.
Attached you can see a screenshot with an "echo $img;" on top of each image.

July 2, 2019 at 3:35 pm #4128479

Matteo

I found this thread: https://wpml.org/forums/topic/acf-image-field-returns-an-array-on-regular-page-and-an-id-on-translated-page/ and I applied some of the advices.

1) I set the _img system field for that custom post and updated the page.
2) I batch duplicated all the posts for that custom type.