All Projects â†’ resume-io â†’ carrierwave-cloudflare

resume-io / carrierwave-cloudflare

Licence: MIT license
🎑 This Rails gem integrates Carrierwave with Cloudflare Image Resizing

Programming Languages

ruby
36898 projects - #4 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to carrierwave-cloudflare

simsg
Semantic Image Manipulation using Scene Graphs (CVPR 2020)
Stars: ✭ 49 (+104.17%)
Mutual labels:  image-manipulation
warpy
A command-line program to get WARP+ as WireGuard written in python
Stars: ✭ 57 (+137.5%)
Mutual labels:  cloudflare
bundle outdated formatter
Formatter for `bundle outdated` command
Stars: ✭ 16 (-33.33%)
Mutual labels:  gem
server-ip-addresses
Daily updated list of IP addresses / CIDR blocks used by data centers, cloud service providers, servers, etc.
Stars: ✭ 74 (+208.33%)
Mutual labels:  cloudflare
uploadcare-ios
UploadcareKit: iOS SDK for Uploadcare API
Stars: ✭ 24 (+0%)
Mutual labels:  image-manipulation
php-proxy
php proxy based on GoAgent protocal,Implemented by golang
Stars: ✭ 85 (+254.17%)
Mutual labels:  cloudflare
Hidden-Eye
Hide data into Picture
Stars: ✭ 39 (+62.5%)
Mutual labels:  image-manipulation
cloudflare-worker-routing
A simple Cloudflare Worker with built-in routing
Stars: ✭ 38 (+58.33%)
Mutual labels:  cloudflare
als typograf
Ruby client for ArtLebedevStudio.RemoteTypograf Web Service.
Stars: ✭ 15 (-37.5%)
Mutual labels:  gem
ImagingKit
Java library for imaging tasks that integrates well with the java.awt.image environment
Stars: ✭ 16 (-33.33%)
Mutual labels:  image-manipulation
image-titler
An image title generator using The Renegade Coder style
Stars: ✭ 15 (-37.5%)
Mutual labels:  image-manipulation
rsgem
Rootstrap way ® to generate gems
Stars: ✭ 26 (+8.33%)
Mutual labels:  gem
worker-auth-providers
worker-auth-providers is an open-source providers to make authentication easy with workers. Very lightweight script which doesn't need a lot of dependencies. Plug it with any framework or template of workers.
Stars: ✭ 85 (+254.17%)
Mutual labels:  cloudflare
nebula
Source Code for the Home Server setup.
Stars: ✭ 48 (+100%)
Mutual labels:  cloudflare
badgemaker
Telegram bot that turns your pictures into Ingress badges
Stars: ✭ 13 (-45.83%)
Mutual labels:  image-manipulation
inkrss
Notify when rss feeds are updated | RSS 更新通知
Stars: ✭ 234 (+875%)
Mutual labels:  cloudflare
cfw-easy-utils
An in-depth library to assist with common tasks with CF Workers. Includes utils for responses, cookies, and more!
Stars: ✭ 52 (+116.67%)
Mutual labels:  cloudflare
sinator
Sinatra application generator
Stars: ✭ 19 (-20.83%)
Mutual labels:  gem
multi-tenancy-devise
mtdevise adds basecamp style user logins to your ruby on rails application.
Stars: ✭ 27 (+12.5%)
Mutual labels:  gem
Cloudflare-dns-update
Allows me to update my CloudFlare dns record so that I can have access to my server with a dynamic IP
Stars: ✭ 35 (+45.83%)
Mutual labels:  cloudflare

CarrierWave::Cloudflare

Tests Gem Version

This gem integrates CarrierWave with Cloudflare Image Resizing

Installation

Add this line to your application's Gemfile:

gem 'carrierwave-cloudflare'

And then execute:

$ bundle install

Or install it yourself with:

$ gem install carrierwave-cloudflare

Usage

Include CarrierWave::Cloudflare in your base uploader

class BaseUploader < CarrierWave::Uploader::Base
  include CarrierWave::Cloudflare
end

Use cdn_transform to define Cloudflare's version (this means that now the file will not be stored on a server, but will be transformed on the Cloudflare side)

class AvatarUploader < BaseUploader
  version(:medium) do
    cdn_transform width: 100, height: 100, dpr: 2
  end
end

user = User.find(some_id)
user.avatar.medium # CarrierWave::Uploader
user.avatar.url # "https://s3.your-website.com/users/avatar/1.jpg"
user.avatar.medium_url   # "https://s3.your-website.com/cdn-cgi/width=100,height=100,dpr=2/users/avatar/1.jpg"
user.avatar.url(:medium) # "https://s3.your-website.com/cdn-cgi/width=100,height=100,dpr=2/users/avatar/1.jpg"
user.avatar.medium.url(dpr: 1) # "https://s3.your-website.com/cdn-cgi/width=100,height=100,dpr=1/users/avatar/1.jpg"
user.avatar.resize(width: 1200, fit: :cover).url # "https://s3.your-website.com/cdn-cgi/width=1200,height=100,dpr=2,fit=cover/users/avatar/1.jpg"

Options

Supported options:

width, height, dpr, fit, gravity, quality, format, onerror, metadata

See details in Cloudflare's documentation

You can also define default options (supports all options described above)

class BaseUploader < CarrierWave::Uploader::Base
  default_cdn_options format: :auto
end

In development env

In development you don't need to generate URLs for Cloudflare, because they will not work and therefore you need to disable the Cloudflare transform

CarrierWave::Cloudflare.configure do |config|
  config.cloudflare_transform(false)
end

cloudflare_transform: false disables links generation and puts all Cloudflare's arguments into query string (for easy debugging)

/1.jpg?cdn-cgi=width-11.height-300.fit-pad

Rails views helpers

cdn_transformed(url, **options)

Returns an image URL with CDN transformations applied. Can process already transformed URLs, in that case the options will be merged together.

cdn_transformed('/img.jpg', width: 400)
# => '/cdn-cgi/image/width=400/img.jpg'

cdn_transformed('/cdn-cgi/image/width=100,fit=pad/img.jpg', width: 333)
# => '/cdn-cgi/image/width=333,fit=pad/img.jpg'

hidpi_image_tag(url, dprs: nil, **options)

Returns an image tag with scaled variations (via srcset) attribute for devices with different DPR values.

The transformation of the original image should be specified via options.

hidpi_image_tag('/bird.jpg', width: 400, drps: [1, 2])
# => <img srcset="/cdn-cgi/image/width=400,dpr=1/img.jpg 1x, /cdn-cgi/image/width=400,dpr=2/img.jpg 2x" src="https://github.com/cdn-cgi/image/width=400/img.jpg" />

responsive_image_tag(url, width:, sizes: nil, dprs: [1, 2], **options)

Returns a reponsive image tag with variations.

responsive_image_tag('/bird.jpg', width: 1200, sizes: { phone: 600, tablet: 800 })

# => <img srcset="/cdn-cgi/image/width=1200,dpr=0.5/bird.jpg 600w,
#                  /cdn-cgi/image/width=1200,dpr=1.0/bird.jpg 1200w,
#                  /cdn-cgi/image/width=1200,dpr=0.67/bird.jpg 800w,
#                  /cdn-cgi/image/width=1200,dpr=1.33/bird.jpg 1600w,
#                  /cdn-cgi/image/width=1200,dpr=2.0/bird.jpg 2400w"
#                  sizes="(max-width: 767px) 600px, (max-width: 1023px) 800px, 1200px"
#                  src="https://github.com/cdn-cgi/image/width=1200/bird.jpg" />

Development

After checking out the repo, run bin/setup to install dependencies. Then run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

License

This project is licensed and distributed under the terms of the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].