Home Forums Front-end Issues ACF and Gravity Forms – Imaged field


ACF and Gravity Forms – Imaged field

  • Hello ACF team,

    I’m using ACF in conjunction with Gravity Forms to allow users to submit posts. It works quite well but I’m still facing a few issues:

    1) GF saves the image URL to ACF custom field. But if I change the picture in the WP-admin panel the image ID is returned in the field (regardless of what option I have set to be the return value). How can I display pictures independent if they have a URL or ID (some if else code I guess?)?
    2) Pictures from GF are not shown in WP-admin panel as preview. I can only see the link.
    3) Is it possible to use GF with the repeater field and the image gallery field I have purchased?

    I think it would be worth investing some time into a tutorial on how to use GF with ACF to display user posts.

    Thanks for your help!

    Here is my code I use to display the pictures:

    $attachment_id = get_field( “homepicture” );
    echo $value ;

    $image_attributes = wp_get_attachment_image_src( $attachment_id, ‘full’ ); // returns an array

    “alt=”” />

    $url = get_post_meta($post->ID, ‘homepicture’, true);

    if ($url) {
    echo “


    (I know its not ideal to use onerror to avoid empty images!)

  • Hi @Robork

    Let me start by saying that GF and ACF are 2 very different plugins and can’t work together in the ways that you want them to. This is due to the different ways that both plugins save data for the same field types.

    1) Yes, you can use a PHP function called is_numeric to find out if the vale from get_field is a number (ACF), or not (GF).
    2) Yes, because GF saves a url instead of a link, ACF can’t read any information about the attachment. There is no solution for this
    3) No, the repeater field is an ACF exclusive and won’t work in any other plugin.


  • I would steer well clear of using Gravity Forms in this way as it such a faff!

    Better to build your own front end posting directly into ACF.

  • Elliot,

    Could you please elaborate on the “GF saves a URL instead of a link”?

    If i pass a text field with the value…

    <img src="">

    … instead of …

    …would that do the trick? Because I’m having no luck with that.

    Gravity forms has a hook called a pre_form_submission that can manipulate the value being sent through the form. I just need to know what the variable that I’m posting to the field should be in order for ACF to pick up the image upon GF submission.

  • Hi @sdawson26

    ACF requires the value (for an image field) to be the attachment ID. If you can use the GF filter to modify the value and change it from the image URL to the image ID, then yes, this will work!


Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘ACF and Gravity Forms – Imaged field’ is closed to new replies.