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.

Dynamically Populating Images Uploaded to Post

  1. jsultemeier
    Member

    Can a set of images that have been uploaded in a post populate a multiple choice and checkbox field?

    I am creating a form that will allow the user to pick one image (multiple choice) and then later select more than one (checkbox).

    Posted 13 years ago on Friday October 7, 2011 | Permalink
  2. I'll have one of our developers take a look and give you some guidance. It's towards the end of the day on Friday so there may be a delay in receiving a response with the weekend, etc. so be patient and i'll make sure someone responds.

    Posted 13 years ago on Friday October 7, 2011 | Permalink
  3. This snippet will populate all of the post images that have been uploaded for the current post the Gravity form is being displayed on. You can indicate which field should display the post images by defining the class as "post-images" in the GF form admin. This code will work with multiple choice fields but may require some additional work for checkboxes. Use it as a base and go from there. :)

    Posted 13 years ago on Monday October 10, 2011 | Permalink
  4. jsultemeier
    Member

    David, thanks for your help!

    It pulled in the images just fine and seems to work well with checkboxes. Only problem I see is when you have more than one multiple choice or checkbox fields; it appears that every time there is another field it adds an extra loop. So, if the first field shows three images, the next displays six and the next displays nine and so on.

    Also, is it possible to return the image name vs the ID?

    Thanks!

    Posted 13 years ago on Tuesday October 11, 2011 | Permalink
  5. Try this: http://pastie.org/2678465

    Posted 13 years ago on Tuesday October 11, 2011 | Permalink
  6. jsultemeier
    Member

    Worked beautifully! This is going to be very nice. I really appreciate it! (Got a donate link?)

    Mixing text and the dynamically populated images in a multiple choice is probably out of the question, huh? (Example: Select the pose you would like to appear in the yearbook: Pic1, Pic2, Pic3, Retake, please) Of course, I could include a "Retake" image.

    Posted 13 years ago on Tuesday October 11, 2011 | Permalink
  7. Since the label is completely separate from the actual value of the field, you can do pretty much whatever you want in the label. In the code above, the label consists of this string on line 20:

    [php]
    "<img src=\"{$image_deets[0]}\" />"

    You could add the image title there as well like so:

    [php]
    "<img src=\"{$image_deets[0]}\" /><br />{$image->post_title}"
    Posted 13 years ago on Tuesday October 11, 2011 | Permalink
  8. jsultemeier
    Member

    Now, to change the size or alignment of the images, I would have thought I could edit the post-images class. I seem to be wrong...

    Posted 13 years ago on Wednesday October 12, 2011 | Permalink
  9. sascha
    Member

    Bookmarked!

    Posted 12 years ago on Tuesday February 7, 2012 | Permalink