Ask A Question

Notifications

You’re not receiving notifications from this thread.

Display Cloudinary image uploads

Nelson Casanova asked in Gems / Libraries

Hello,

I've been trying to solve a problem I've got when trying to display images from Cloudinary. I setup everyhting accounding to the guide they provide and basically I need to upload images from Trix editor. All this works ok. I can create a new 'post' and add images and I can see them get uploaded to Cloudinary but when I go to the actual post I see a broken link to the image.

It links to something like:
https://www.website.com/rails/active_storage/representations/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBEUT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--840bc40935cd84bca5e9d91a61a417548af73f46/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCam9VY21WemFYcGxYM1J2WDJ4cGJXbDBXd2RwQWdBRWFRSUFBdz09IiwiZXhwIjpudWxsLCJwdXIiOiJ2YXJpYXRpb24ifX0=--e8b64f915dd57a02094ca6aabd25a6fa92ba975b/wvgq2bftvea31.png

and when I check the image over at Cloudinary the URL should be something like:

https://res.cloudinary.com/your-application/image/upload/v1599605569/mw5yd8iftpmzq7peqwjk8ot3htbw.png

My /views/active_storage/blobs/_blob.html.erb file looks like the default:

<figure class="attachment attachment--<%= blob.representable? ? "preview" : "file" %> attachment--<%= blob.filename.extension %>">
  <% if blob.representable? %>
    <%= image_tag blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ]) %>
  <% end %>

  <figcaption class="attachment__caption">
    <% if caption = blob.try(:caption) %>
      <%= caption %>
    <% else %>
      <span class="attachment__name"><%= blob.filename %></span>
      <span class="attachment__size"><%= number_to_human_size blob.byte_size %></span>
    <% end %>
  </figcaption>
</figure>

Any ideas how to grab the image from the cloud instead of that weird looking local storage link?

Reply

anyone get the answer? thanks. curious I'm having some issue too regarding this.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 87,400+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.