Comments (9)
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.
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.
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.
@brendanmatkin there are actually 2 cloudinary_url
methods:
One is here:
cloudinary_gem/lib/cloudinary/helper.rb
Line 235 in 088330b
And another one is here:
cloudinary_gem/lib/cloudinary/utils.rb
Line 882 in 088330b
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.
@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.
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.
Ok sounds good! Thanks for the engagement and help so far.
from cloudinary_gem.
Hi @brendanmatkin ,
Please note that this issue was fixed.
Thanks,Wissam
from cloudinary_gem.
@wissam-khalili Nice, thanks for updating me!! Appreciate y'all getting on this obscure bug.
from cloudinary_gem.
Related Issues (20)
- Cant direct upload raw files HOT 17
- Some kind of overlay texts generate urls which cause `400 Bad Request` HOT 7
- Support Dynamic Folder upload parameters HOT 2
- How to get value txt file? HOT 3
- Update API is missing metadata support HOT 3
- Conditional metadata rules support HOT 6
- Broken urls - Unsafe characters in public_id are not properly escaped by Cloudinary::Utils.cloudinary_url HOT 2
- Photo metadata is nil until after AR callbacks have run HOT 7
- Unable to upload multiple images to cloudinary HOT 1
- ActiveStorage: Non-image file is not deleted when its blob is destroyed HOT 4
- ActiveStorage support for upload_large HOT 2
- Update sample projects dependencies HOT 4
- preview:duration effect was shortened to preview:du when uploading a video HOT 1
- Access token url generation returns 404 HOT 2
- The gem breaks the lazy loading of ActionView::Base HOT 1
- Contextual metadata support for url_for_direct_upload HOT 2
- Transformation params not properly URL escaped HOT 3
- 2.0: Rake task fail with `LoadError` on `faraday/follow_redirects` HOT 4
- Cannot view an image using the cl_image_tag after a new upload, getting key not found: :type error HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cloudinary_gem.