Coder Social home page Coder Social logo

Comments (9)

wissam-khalili avatar wissam-khalili commented on June 11, 2024 1

Hi @brendanmatkin,

Thank you for your feedback.
You are right, it's a bug and we will fix it.
We will keep you posted.

Thanks,
Wissam

from cloudinary_gem.

wissam-khalili avatar wissam-khalili commented on June 11, 2024

Hi @brendanmatkin,

The cl_image_tag method described above generates an HTML image tag. In certain conditions, you might want to generate a transformation URL directly, without the containing image tag. To return only the URL, either use the cl_image_path or cloudinary_url view helper methods, or use the Ruby command: Cloudinary::Utils.cloudinary_url.
You read about it here:
https://cloudinary.com/documentation/rails_image_manipulation#direct_url_building

I hope you find it useful.

Regards,
Wissam

from cloudinary_gem.

brendanmatkin avatar brendanmatkin commented on June 11, 2024

Thanks @wissam-khalili.

My above issue is true for those commands (cl_image_path and cloudinary_url) as well. None of those build remote fetch URLs correctly.

The Storage Service Config folder should not be included those URL builders for remote fetch (cloudinary does not expect the folder in remote fetch URL, because remote fetches don't have folders).

The only way to make it work is to build the url manually. The bug still exists though even though the workaround is documented.

Here is my manual URL builder if anyone else has the same problem (obviously the transformations are specific to my use case and URL signing is enabled).

def cloudinary_url_manual(url, width, height)
  transformation = "c_lfill,h_#{height},w_#{width}/q_auto/f_auto"
  public_id = escape(url) # can prepend with folder if using
  to_sign = [transformation, public_id].join("/")
  secret = Rails.application.credentials.dig(:cloudinary, :api_secret)
  signature = "s--#{Base64.urlsafe_encode64(Digest::SHA1.digest(to_sign + secret))[0, 8]}--"
  cloud_name = Rails.application.credentials.dig(:cloudinary, :cloud_name)
  "https://res.cloudinary.com/#{cloud_name}/image/fetch/#{[signature, to_sign].join('/')}"
end

def escape(url)
  url.gsub("?", "%3F").gsub("&", "%26").gsub("=", "%3D")
end

from cloudinary_gem.

const-cloudinary avatar const-cloudinary commented on June 11, 2024

@brendanmatkin there are actually 2 cloudinary_url methods:
One is here:

def cloudinary_url(source, options = {})
(which most likely you are calling)

And another one is here:

def self.cloudinary_url(public_id, options = {})

The latter one should be good for building fetch URLs.
And you can call it like: Cloudinary::Utils.cloudinary_url(<REMOTE_URL>, type: "fetch", transformation: [{ fetch_format: :auto }])

from cloudinary_gem.

brendanmatkin avatar brendanmatkin commented on June 11, 2024

@const-cloudinary ah ok! I'm still getting the hang of Ruby/Rails, and I'm not sure if I realized I could use the cloudinary_url Ruby utility command in a view. I think I was thinking that the first was only for views and the second was only for controllers (I'm using this in views).

I THINK we tried the second one at some point, but I can't be sure (it might've been under different circumstances - there are 2 apps that use Cloudinary remote fetch). Thanks for clarifying either way! I will try this again soon - hopefully that was my issue.

from cloudinary_gem.

brendanmatkin avatar brendanmatkin commented on June 11, 2024

p.s. @wissam-khalili thanks also for your help - I misinterpreted that you were showing me 2 different cloudinary_url methods.

Along these same lines, should the non-utility method still be able to work with remote fetch? It seems to take the option, but it definitely doesn't work. If so, this could still be a valid bug, right?

from cloudinary_gem.

brendanmatkin avatar brendanmatkin commented on June 11, 2024

Ok sounds good! Thanks for the engagement and help so far.

from cloudinary_gem.

wissam-khalili avatar wissam-khalili commented on June 11, 2024

Hi @brendanmatkin ,

Please note that this issue was fixed.
Thanks,Wissam

from cloudinary_gem.

brendanmatkin avatar brendanmatkin commented on June 11, 2024

@wissam-khalili Nice, thanks for updating me!! Appreciate y'all getting on this obscure bug.

from cloudinary_gem.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.