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.

File upload as attachment ID

  1. daleanthony
    Member

    I'm using the file upload custom field in a form to allow users to upload images, at the moment these images are passed through to the custom field as a URL, ideally I'd like the attachment ID passed through rather than URL so that it will work with another plugin I am using.

    Does anyone have any idea if this is possible?

    Thanks.
    DW.

    Posted 12 years ago on Monday January 2, 2012 | Permalink
  2. Do you want to store the attachment ID in the custom field and then be able to use that in another plugin?

    Posted 12 years ago on Tuesday January 3, 2012 | Permalink
  3. daleanthony
    Member

    Yes, exactly, also all the calls from the template files for my theme use the attachment ID :)

    Posted 12 years ago on Tuesday January 3, 2012 | Permalink
  4. This might help, ps you need some DEFINE constants and other hardcoded vars tweaks before you can use this.
    This is a partial copy paste of a form I use to update images attached to a specific post.

    http://www.pastie.org/3125156

    Posted 12 years ago on Wednesday January 4, 2012 | Permalink
  5. daleanthony
    Member

    Thanks!

    I'll have to spend some time trying to figure out how to get this working with my setup properly. Any idea if this can be modified to do the same thing to multiple fields?

    Posted 12 years ago on Wednesday January 4, 2012 | Permalink
  6. Sure, make a loop ;)

    Posted 12 years ago on Wednesday January 4, 2012 | Permalink
  7. wkks
    Member

    Hey Dale,

    I'm actually using the 'after_submission' filter/hook to attach my images to the post as an ID.

    http://www.pastie.org/3167687

    KW

    Posted 12 years ago on Wednesday January 11, 2012 | Permalink
  8. daleanthony
    Member

    @wkks thanks this works brilliantly!

    Just wondering if there is a way the code can be modified to count how many of these fields have data in them and place the number in another custom field?

    eg. If 'image 1' and 'image 2' have been uploaded the the count of the field 'image-count' would be set to 2

    Posted 12 years ago on Monday January 16, 2012 | Permalink
  9. sascha
    Member

    That is all great. counting images would be good too!

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