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.

Save image metadata (id, url ..) in a custom meta data field after post creation

  1. Hello,

    I'd like to save image metadata (id, url, title, description) into a custom metadata fields after a form has been submitted and a post has been created.

    I figured out that I have to use gform_after_submission hook, so I can see the value per image with all the required data that looks like
    http://example.com/wp-content/uploads/gravity_forms/2-f3d72372c784de1b17f8507432c30d29/2013/03/image_file.jpg|:|FF S4 Image 1|:||:|FF S4 Image 1 Descr|:|117

    Is there a GF function I should use to extract that data (in case there is one, so it will be compatible with any future changes).

    OR do I have to do it myself something like:
    list($url, $title, $caption, $description) = explode("|:|", $value);

    Just wanted to make sure to use native way, to make sure it's more robust for future changes if any.

    Many thanks, Dasha

    Posted 11 years ago on Friday March 15, 2013 | Permalink
  2. From the code in entry_list.php:

    [php]case "post_image" :
        list($url, $title, $caption, $description) = rgexplode("|:|", $value, 4);

    You have it exactly right. I would use rgexplode as shown there, with the 3rd parameter, but otherwise I don't see any other native functions to handle this.

    Posted 11 years ago on Sunday March 17, 2013 | Permalink
  3. Hello Chris,

    Thanks very much for letting me know to use rgexplode. Works well for extracting img meta data to store it in custom meta fields.

    Dasha

    Posted 11 years ago on Monday March 18, 2013 | Permalink
  4. You're welcome.

    Posted 11 years ago on Monday March 18, 2013 | Permalink

This topic has been resolved and has been closed to new replies.