Skip to content
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

[Bug]: ACF image doesn't get properly stored or retrieved when using in ACF and wp_get_attachment_image() #146

Open
1 task done
stefthoen opened this issue May 2, 2023 · 1 comment

Comments

@stefthoen
Copy link

stefthoen commented May 2, 2023

Description of the bug

I'm using this plugin together with ACF. If I use a normal ACF Image field on a page and try to retrieve a globally shared image with wp_get_attachment_image(), I get an empty string as a return value.

I did some exploring and acfLoadValue() gets triggered and the image gets stored in ACF's cache, but it's either unsuccessful in storing or retrieving the image from said cache, and I think the issue is storing the image, because just the image id is getting stored. If I var_dump the $formatted value in ACF/Image.php I get only the image id.

If I 'manually' run switch_to_blog(1) before wp_get_attachment_image() and restore_blog() after, I'm successful in retrieving the image, but that seems rather cumbersome and invasive.

What would be the best way to debug this issue? How should the image be stored in the ACF_Data store?

Reproduction instructions

  1. Add a globally shared image with ACF
  2. Use wp_get_attachment_image() to load the image.

Expected behavior

I'm successful loading a globally shared image in a ACF with wp_get_attachment_image().

Environment info

  • The latest release of this plug-in
  • Any browser
  • Roots Sage theme

Code of Conduct

  • I agree to follow this project's Code of Conduct
@stefthoen stefthoen changed the title [Bug]: ACF image doesn't get properly stored or retrieved when used in ACF blocks [Bug]: ACF image doesn't get properly stored or retrieved when using in ACF and wp_get_attachment_image() May 2, 2023
@JacEngels
Copy link

Any update on this issue? I'm running into the same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants