-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow UPLOADCARE_CDN_BASE setting. #24
Comments
yup, just replace whatever CDN prefix you have with https://ucarecdn.com |
@dmitry-mukhin why this isn't an option on uploadcare.yml file? |
gem is bit outdated. |
👍 really needed |
Is this still a planned enhancement or is there a known workaround? |
@Oshuma you can always add this setting (along with any other) to your HTML or templates manually without gem's help. Does it make sense? |
@dmitry-mukhin I can add the setting manually to templates, and it does use the CDN URL when saving to the model attribute, however any subsequent methods that use the model's // Widget setting:
UPLOADCARE_CDN_BASE = "https://ucarecdn.example.com"; # Image model:
# has_uploadcare_file :uploadcare
image = Image.last
# In the database, the field is saved using the correct CDN URL:
# uploadcare: "https://ucarecdn.example.com/e379b8b7-178a-4fb5-8729-e1bfec0b1a7e/"
# However, using #to_s or #url returns the standard UC CDN:
image.uploadcare.url
# => "https://ucarecdn.com/e379b8b7-178a-4fb5-8729-e1bfec0b1a7e/"
image.uploadcare.to_s
# => "https://ucarecdn.com/e379b8b7-178a-4fb5-8729-e1bfec0b1a7e/"
image.uploadcare.url(inline: "/scale_crop/80x80/center")
# => "https://ucarecdn.com/e379b8b7-178a-4fb5-8729-e1bfec0b1a7e/-/scale_crop/80x80/center/" |
So a workaround that I think is working is setting # ./config/uploadcare.yml
cdn_base: "https://ucarecdn.example.com"
static_url_base: "https://ucarecdn.example.com" [1] pry(main)> image = Image.first
=> # uploadcare: "https://ucarecdn.com/170f0b2d-4e1a-4997-8e22-4f4600cd9ca1/"
[2] pry(main)> image.uploadcare.to_s
=> "https://ucarecdn.example.com/170f0b2d-4e1a-4997-8e22-4f4600cd9ca1/"
[3] pry(main)> image.uploadcare.url(inline: "/scale_crop/80x80/center")
=> "https://ucarecdn.example.com/170f0b2d-4e1a-4997-8e22-4f4600cd9ca1/-/scale_crop/80x80/center/" |
@dmitry-mukhin Are you aware of any side effects of that ^ workaround (setting the |
@Oshuma I'd say that you're safe to use that hack. |
@dmitry-mukhin I've made that change in our production app and have it deployed. It seemed to do the trick. All images are successfully getting uploaded and served through our CDN. |
👍 |
I actually didn't have to change any code in the library, only added that |
@boxmo, Hi, we released a new v2 version of the gem. You can set this param in the initializer in v2 ( |
There's a way that i can load images on https protocol?
The text was updated successfully, but these errors were encountered: