Dynamically assign tags using cl_image_upload_tag
I'm building an image gallery where users can tag and upload images. I'm using php/jquery and the cl_image_upload_tag to build the direct upload field. I was looking at the "more upload option" form in the media library and it looks like you guys are using jQuery to dynamically add the tags to the direct upload field. Can you share that code? Or post example code?
-
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:
"tags":"direct_photo_album"
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?
0 -
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.
0 -
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."0
Post is closed for comments.
Comments
3 comments