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

Cropped images are not visible in rest API #115

Open
Pitrsn opened this issue Sep 6, 2022 · 5 comments
Open

Cropped images are not visible in rest API #115

Pitrsn opened this issue Sep 6, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@Pitrsn
Copy link

Pitrsn commented Sep 6, 2022

Hello,

We are working with this plugin in rest API based site.
All data is loaded via wp2 json rest api in multisite wordpress

We defined new customfields
image

Enabled option for show in rest API
image

and filled these customFields with images
image

Unfortunately these new customfields with cropped images are not visible in output json. Only customfields with "basic" setup are visible.
image

Can u help me pls? thank you

@Pitrsn Pitrsn changed the title Cropped fields are not visible in rest API Cropped images are not visible in rest API Sep 6, 2022
@joppuyo
Copy link
Owner

joppuyo commented Sep 7, 2022

Hey. I’m not planning on adding any more features to the 6.x branch of the plugin but I will take a look at this after 7.x release.

@joppuyo joppuyo added the enhancement New feature or request label Sep 7, 2022
@Pitrsn
Copy link
Author

Pitrsn commented Sep 7, 2022

Thank you for your reply.

Do you have some plans, when version 7 will be live?
Thank you

@leok85
Copy link

leok85 commented Mar 8, 2023

@Pitrsn
If you place the image field inside a field group it appears in the REST API.
I have the same problem, but by doing this you can work around the problem.

@leok85
Copy link

leok85 commented Mar 8, 2023

Or you can modify the api response from the entire route, like so:

I have a custom post type named courses:

add_action( 'rest_api_init',  function(){
	register_rest_field( 'courses', 'acf', array(
		'get_callback' => function () { return get_fields(); }
	));
});

@Simbaclaws
Copy link

Simbaclaws commented Jul 21, 2023

I tried putting the field in a field group, and also added show_in_rest for both the field and the field group, but it still won't show up in my REST API.

What should I try to get this to show up? Other fields in the same field group do show up...

EDIT:
@leok85 your code does seem to work, thank you :)

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

No branches or pull requests

4 participants