-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WP ACF repeater with image bug #3009
Comments
The data for images in the ACF repeater field are still visible via the REST API, but are being stripped out in the app's GRAPHQL- I think this is occurring in the normalise.js mapEntitiesToMedia function but I'm not yet sure. Is there any way of resolving this? |
I'm closing this issue as it appears to be the result of a particular image file, or group of images- we can track their urls and data through the various normalise.js functions without an obvious reason for them causing a problem- but they do. When we remove and replace these image files the site runs correctly on both |
I have realised that this is not as above mentioned the result of particular images. My site was working correctly until I added another AFC component which contained images. This then not only caused a graphql error on the new ACF field but also some of the previously working ones. Where images were displaying correctly previously, the terminal now displays the following error When an image is added in Wordpress it has a value of I appreciate any help or pointers anybody can give to prevent this happening. Thanks very much in advance! |
I have further narrowed this bug down to being caused when an image is added to the first item of a repeater field. I have found that a hacky way of getting round this bug is to remove the image from the first item in a repeater field and then discard the first item when looping through the data in the front end. It would be great if this bug could be ironed out relatively soon as we'd like to deploy an e-commerce site we're working on in the coming weeks and the hack-fix is likely to confuse the client. Appreciate any help that can be given! |
Hi @craig-doyle-uk |
Hi @sebastienfi , thanks for the response! eg with image added to all elements in an acf repeater :
With the first image removed :
This bug only occurs intermittently, with everything working well most of the time, but then failing on some pages. In some cases the repeater with Graphql is working perfectly until we add another page and then a page that is working then stops working! I have no idea of what is happening but I think it is occurring in the |
I ran into a similar issue when using just an Image field in a simple field group. This is actually an issue with how ACF returns when an image is not set. Checkout the Image field in the ACF repo.. |
I ran into the same issue too I think... I query my post content with flexible contents acf fields, which cause images to return null that are not in the flexible content layout, but I really don't know why :( |
Well I tried to get more information about where this bug is coming from, but all I found out that in my case only one post get the right value of each acf field. |
I think this is loosely related to this issue around non-existing fields and GraphQL.. |
I have found two causes for this and a similar bug (elements being added in WP via ACF with FC not available in Gatsby app).
Hope this helps in some cases! |
I might have the solution, taken from this issue. I had this exact same issue. Working perfectly before - GraphQL was able to query image IDs and URLs and Gatsby was merrily displaying the image URLs. Then I added another flexible content field which contained an Image upload field (I'd used this flexible content field previously on a different page). I was getting
I tried what was suggested by @craig-doyle-uk :- changing the Return Value from Image Array to Image URL and back to Image Array, then resaved the two pages with these fields used. I also tried the other, earlier suggestion of removing the first item and adding it back in. Still no luck. I took a look at @jsanchez034 's referenced issue. Still didn't fix my issue. Finally I looked at @kennethormandy 's reference to #4461 and that had the solution for me. As per the above post, in my WordPress theme's function nullify_empty($value, $post_id, $field)
{
if (empty($value)) {
return null;
}
return $value;
}
add_filter('acf/format_value/type=image', 'nullify_empty', 100, 3); Now my images are querying correctly in GraphQL, Gatsby is running and images in repeatable flexible fields are displaying correctly, while those that don't have them also display correctly. Hope this helps someone else. |
After spending hours on searching a fix for this issue, I came up with my own solution. Add the following function in your `function set_acf_image_source_url_empty($value, $post_id, $field) {
} I hope this helps :) |
Node version v6.7.0
Gatsby version 1.9.108
gatsby-config.js :
gatsby-node.js
pacjage.json :
We have an issue whereby our site works correctly when we add a page with a repeater that includes maybe 3 or 4 images (in the above case the field is named article_image). When we then create a couple more similar pages the site stops working with the following error in our gatsby-node.js graphQL results callback.
GraphQLError: Field "article_image" must not have a selection since type "Boolean" has no subfields.
We can see when removing
source_url
as suggested that image just has a value ofnull
If we delete the article_image acf field and create a new one with another name the site works again until we have added a few images and then the same issue occurs on the new field. We've tested a few things on the backend such as increasing the memory for WP as we thought it could be related to WP but it doesn't appear to be as the images are still displaying correctly in the CMS- but are not accessible from the Gatsby app.
The text was updated successfully, but these errors were encountered: