metadata - How to retreive image captions from cloudinary and rails? -
i'm trying add caption below cloudinary image. on cloudinary website, i've added caption under "edit metadata" field, can't figure out how retrieve it.
my controller:
require 'cloudinary' results = cloudinary::api.resources(:type => :upload) resources = results["resources"] @ids = resources.map {|res| res["public_id"]}
my view:
<% @ids.each |id| %> <%= cl_image_tag (id) %> **insert caption here** <% end %>
to image metadata you've inserted, you'll have set context
true
when running resources
method, this:
results = cloudinary::api.resources(:type => :upload, :context => true)
the above request return key-value pairs in metadata you've inserted, this:
"context"=>{"custom"=>{"caption"=>"flowers"}}
Comments
Post a Comment