PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

image uploads

  1. I have a form that I am creating, which creates a post and allows users to upload images. My problem is the I wont know how many images the user will upload, so is there a way to hide the output of any blank spots that are not uploaded? Right now the blank posts look like this
    http://www.georgiahomesforrent.net/?p=1852

    Posted 7 years ago on Tuesday November 20, 2012 | Permalink
  2. David Peralty
    Administrator

    How are you currently coding the output to work? Can you check for null values using PHP before you output the values?

    Posted 7 years ago on Tuesday November 20, 2012 | Permalink
  3. I am using the "file upload" and I have about 5 of them only because I want to make sure there are sufficient files for the user to upload. Don't want to sound like an idiot, (too late ;D) How do I check null values?

    Posted 7 years ago on Tuesday November 20, 2012 | Permalink
  4. David Peralty
    Administrator

    Gravity Forms doesn't display images in posts by default. So I would have to know how you are displaying them in your post. If you are just using the Content Template option for the Post Body, then there is no way of testing for null values.

    Posted 7 years ago on Tuesday November 20, 2012 | Permalink
  5. "If you are just using the Content Template option for the Post Body,".....
    I am using using the post body option. I've been told in a previous forum post that that's the only way to create posts from the user content.

    Posted 7 years ago on Tuesday November 20, 2012 | Permalink
  6. David Peralty
    Administrator

    While it is the main way, for images, custom fields could have been used, then I could have pointed you to some tutorials for PHP and custom fields where you could have tested for values, and then shown the image only if there was a value in the field. Unfortunately, with how it is currently set-up, I don't know of any way to hide the images that don't have values.

    I'll check with the development team to see if they have any ideas.

    Posted 7 years ago on Tuesday November 20, 2012 | Permalink
  7. The photos are the last items I have listed, I can probably use custom fields if you let me know how I can do that?

    Posted 7 years ago on Tuesday November 20, 2012 | Permalink
  8. Andrea, I got a 404 response for the link in your first post. Do you have an updated link? Actually, do you have a link to your form online, and a post which is created from that form? Thank you.

    Posted 7 years ago on Wednesday November 21, 2012 | Permalink
  9. sorry, I deleted the post, here, try this one

    http://www.georgiahomesforrent.net/?p=1901

    Posted 7 years ago on Friday December 14, 2012 | Permalink
  10. sorry, I'm being an airhead, didnt read your answer entirely.... the link for the test post that was created from the form is

    http://www.georgiahomesforrent.net/?p=1901

    and the preview link for the form is

    http://georgiahomesforrent.net/?gf_page=preview&id=1

    Posted 7 years ago on Friday December 14, 2012 | Permalink
  11. I see the post which was created, but I did not see the form. I see the problem. Right now, the content template will have spaces for all the images, and when there is no image uploaded, the space is still taken up in the post as if an image were uploaded.

    You won't be able to use the content template like this, if you want to avoid outputting empty image. You might want to use the content template for everything except the images, then loop through the images in a function using the gform_after_submission hook. If the image upload is empty, then don't output the image tag.

    http://www.gravityhelp.com/documentation/page/Gform_after_submission

    You could also add a [gallery] shortcode, which will output all attached images based on however you have configured the shortcode, with no blank images being output.

    Posted 7 years ago on Saturday December 22, 2012 | Permalink