Skip to main content

Dynamically assign tags using cl_image_upload_tag



  • Admin Tnsfic

    I've played around with this a bit since my original post.  I have a onchange function on my tags field that will get the 'data-form-data' attribute of the direct upload field.  I pluck out and change the tags and then change the 'data-form-data' to include the new tags.

    so, this:


    becomes this:

    "tags":"direct_photo_album, testing"


    When I upload the image, only the direct_photo_album tag is being set.  Do I need to set the new tags somewhere else besides in the 'data-form-data' attribute? 

  • Curt McCorkle

    Im having trouble with this also. I added the "tags" field to my upload config and the tag does not get added to the uploaded image. 

  • Admin Tnsfic

    I ended up getting email support for this issue.  Here's how it was resolved


    Regarding your question, the signature needs to be updated if tags are added.

    This means that you will need to perform an ajax request to get the updated formData.

    You can do (with the latest php library):

    $params = Cloudinary\Uploader::build_upload_params($options);
    $params = Cloudinary::sign_request($params, $options);
    $json = json_encode($params);

    To create the updated form data ($options is the same as you passed to cl_image_upload_tag but with the two tags)

    To update the fileupload widget on the javascript side, you can use $('.cloudinary-fileupload').fileupload({formData: data}) where data is the deserialized json created above."




Post is closed for comments.