You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Add a globally shared image with ACF
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
The text was updated successfully, but these errors were encountered:
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
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 Ivar_dump
the$formatted
value inACF/Image.php
I get only the image id.If I 'manually' run
switch_to_blog(1)
beforewp_get_attachment_image()
andrestore_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
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
Code of Conduct
The text was updated successfully, but these errors were encountered: