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

Image field return_format returns an ID instead of array or URL #163

Open
marcinkrzeminski opened this issue Nov 6, 2022 · 2 comments
Open

Comments

@marcinkrzeminski
Copy link

Hi,

I have an image field added like this

->addImage('image', [
            'label' => __('Image'),
            'return_format' => 'url'
        ])

As per docs, this should return a URL to the image. Unfortunately, I'm getting and ID in the response.

public 'acf' => 
    object(stdClass)[12748]
      public 'email' => string '[email protected]' (length=21)
      public 'image' => int 875
      public 'bio' => string '' 

Any idea what could be wrong here?

@timlogemann
Copy link

I noticed the same for radio and other fields where the return_format option can be provided. It always seems to return the default setting rather than the value provided. For a radio I tried setting it to both label and array, but it still returns just the value.

For example this radio:

->addRadio('language', ['return_format' => 'array'])
  ->setConfig('label', __('Language', 'deerns'))
  ->setConfig('return_format', 'array')
  ->setConfig('required', true)
  ->addChoices([
    'nl' => __('Dutch', 'deerns'),
    'en' => __('English', 'deerns'),
    'fr' => __('French', 'deerns'),
    'de' => __('German', 'deerns'),
    'it' => __('Italian', 'deerns'),
    'pt' => __('Portuguese', 'deerns'),
    'es' => __('Spanish', 'deerns')
  ])```

as you can see I've tried setting the return_format in both the inline settings array as well as with the setConfig option, after trying them both separately, but they have no effect. The field only returns 'es' for example.

@ernilambar
Copy link

I tested Image and Radio fields and both are working fine. Can you please provide sample code how are you fetching the ACF field value?

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

3 participants