imagekitio-rails 1.0.0.beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CONTRIBUTING.md +107 -0
- data/LICENSE +201 -0
- data/README.md +81 -0
- data/lib/active_storage/service/image_kit_service.rb +15 -0
- data/lib/imagekit/rails/active_storage/blob_deletion_callback.rb +75 -0
- data/lib/imagekit/rails/active_storage/service.rb +360 -0
- data/lib/imagekit/rails/active_storage.rb +9 -0
- data/lib/imagekit/rails/configuration.rb +103 -0
- data/lib/imagekit/rails/helper.rb +338 -0
- data/lib/imagekit/rails/railtie.rb +26 -0
- data/lib/imagekit/rails/version.rb +9 -0
- data/lib/imagekitio-rails.rb +84 -0
- metadata +158 -0
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Imagekit
|
|
4
|
+
module Rails
|
|
5
|
+
# View helpers for generating ImageKit image and video tags
|
|
6
|
+
#
|
|
7
|
+
# This module provides Rails view helpers that generate `<img>` and `<video>` tags
|
|
8
|
+
# with ImageKit URLs, including transformations, responsive images, and signed URLs.
|
|
9
|
+
#
|
|
10
|
+
# These helpers are automatically included in all Rails views and controllers
|
|
11
|
+
# when the gem is loaded (via the Railtie), so you can use them directly without
|
|
12
|
+
# any additional setup.
|
|
13
|
+
#
|
|
14
|
+
# @example Using in views (automatically available)
|
|
15
|
+
# <%= ik_image_tag("/photo.jpg", width: 400) %>
|
|
16
|
+
# <%= ik_video_tag("/video.mp4", controls: true) %>
|
|
17
|
+
#
|
|
18
|
+
# @see #ik_image_tag
|
|
19
|
+
# @see #ik_video_tag
|
|
20
|
+
module Helper
|
|
21
|
+
# Generates an image tag with ImageKit URL transformations and responsive image support.
|
|
22
|
+
#
|
|
23
|
+
# @param src [String, ActiveStorage::Attached] Image path or Active Storage attachment
|
|
24
|
+
# @param options [Hash] Image tag options
|
|
25
|
+
#
|
|
26
|
+
# @option options [String] :url_endpoint ImageKit URL endpoint (overrides config)
|
|
27
|
+
# @option options [Array<Hash>] :transformation Array of transformation objects.
|
|
28
|
+
# See [Transformation docs](https://www.gemdocs.org/gems/imagekitio/4.0.0/Imagekitio/Models/Transformation.html) for all available parameters
|
|
29
|
+
# @option options [Hash{Symbol=>String}] :query_parameters Additional query parameters
|
|
30
|
+
# @option options [Symbol] :transformation_position Position for transformations - `:path` or `:query` (default: `:query`).
|
|
31
|
+
# See [TransformationPosition](https://www.gemdocs.org/gems/imagekitio/4.0.0/Imagekitio/Models/TransformationPosition.html)
|
|
32
|
+
# @option options [Boolean] :signed Whether to generate a signed URL (default: `false`)
|
|
33
|
+
# @option options [Integer, Float] :expires_in Expiration time in seconds for signed URLs.
|
|
34
|
+
# If specified, URL will always be signed. See [Signed URLs](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls)
|
|
35
|
+
#
|
|
36
|
+
# @option options [Boolean] :responsive Enable/disable responsive images with `srcset` (default: `true`)
|
|
37
|
+
# @option options [Array<Integer>] :device_breakpoints Device width breakpoints for responsive images
|
|
38
|
+
# @option options [Array<Integer>] :image_breakpoints Image width breakpoints for responsive images
|
|
39
|
+
# @option options [String] :sizes Sizes attribute for responsive images (e.g., `"(max-width: 600px) 100vw, 800px"`)
|
|
40
|
+
#
|
|
41
|
+
# @option options [String] :alt Alt text for the image
|
|
42
|
+
# @option options [Integer, String] :width Width attribute for the img tag
|
|
43
|
+
# @option options [Integer, String] :height Height attribute for the img tag
|
|
44
|
+
# @option options [String] :loading Loading strategy - `"lazy"` (default) or `"eager"`
|
|
45
|
+
# @option options [String] :class CSS classes
|
|
46
|
+
# @option options [Hash] :data Data attributes (e.g., `{ controller: "gallery", action: "click" }`)
|
|
47
|
+
#
|
|
48
|
+
# @return [String] HTML image tag with ImageKit URL
|
|
49
|
+
#
|
|
50
|
+
# @see https://www.gemdocs.org/gems/imagekitio/4.0.0/Imagekitio/Models/SrcOptions.html SrcOptions model
|
|
51
|
+
# @see #ik_video_tag
|
|
52
|
+
#
|
|
53
|
+
# @example Basic usage
|
|
54
|
+
# ik_image_tag("/path/to/image.jpg", alt: "My Image")
|
|
55
|
+
#
|
|
56
|
+
# @example With Active Storage
|
|
57
|
+
# ik_image_tag(user.avatar, alt: "User Avatar")
|
|
58
|
+
#
|
|
59
|
+
# @example With transformations
|
|
60
|
+
# ik_image_tag(
|
|
61
|
+
# "/path/to/image.jpg",
|
|
62
|
+
# transformation: [{ width: 400, height: 300 }],
|
|
63
|
+
# alt: "Resized Image"
|
|
64
|
+
# )
|
|
65
|
+
#
|
|
66
|
+
# @example With responsive images
|
|
67
|
+
# ik_image_tag(
|
|
68
|
+
# "/path/to/image.jpg",
|
|
69
|
+
# width: 800,
|
|
70
|
+
# sizes: "(max-width: 600px) 100vw, 800px",
|
|
71
|
+
# alt: "Responsive Image"
|
|
72
|
+
# )
|
|
73
|
+
#
|
|
74
|
+
# @example With overlays
|
|
75
|
+
# ik_image_tag(
|
|
76
|
+
# "/background.jpg",
|
|
77
|
+
# transformation: [{
|
|
78
|
+
# overlay: {
|
|
79
|
+
# type: "text",
|
|
80
|
+
# text: "Hello World",
|
|
81
|
+
# transformation: [{ fontSize: 50, fontColor: "FFFFFF" }]
|
|
82
|
+
# }
|
|
83
|
+
# }],
|
|
84
|
+
# alt: "Image with text overlay"
|
|
85
|
+
# )
|
|
86
|
+
def ik_image_tag(src, options = {})
|
|
87
|
+
# Handle Active Storage attachments
|
|
88
|
+
if active_storage_attachment?(src)
|
|
89
|
+
return nil unless src.attached?
|
|
90
|
+
|
|
91
|
+
src = src.blob.key
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
raise ArgumentError, 'src is required' if src.nil? || src.empty?
|
|
95
|
+
|
|
96
|
+
config = Imagekit::Rails.configuration
|
|
97
|
+
helper = config.client.helper
|
|
98
|
+
|
|
99
|
+
# Extract ImageKit-specific options
|
|
100
|
+
url_endpoint = options.delete(:url_endpoint) || config.url_endpoint
|
|
101
|
+
transformation = options.delete(:transformation) || []
|
|
102
|
+
query_parameters = options.delete(:query_parameters)
|
|
103
|
+
transformation_position = options.delete(:transformation_position) || config.transformation_position
|
|
104
|
+
responsive = options.key?(:responsive) ? options.delete(:responsive) : config.responsive
|
|
105
|
+
signed = options.delete(:signed)
|
|
106
|
+
expires_in = options.delete(:expires_in)
|
|
107
|
+
|
|
108
|
+
# Extract HTML attributes
|
|
109
|
+
alt = options.delete(:alt) || ''
|
|
110
|
+
width = options.delete(:width)
|
|
111
|
+
height = options.delete(:height)
|
|
112
|
+
sizes = options.delete(:sizes)
|
|
113
|
+
loading = options.delete(:loading) || 'lazy'
|
|
114
|
+
css_class = options.delete(:class)
|
|
115
|
+
data_attributes = options.delete(:data)
|
|
116
|
+
device_breakpoints = options.delete(:device_breakpoints) || config.device_breakpoints
|
|
117
|
+
image_breakpoints = options.delete(:image_breakpoints) || config.image_breakpoints
|
|
118
|
+
|
|
119
|
+
# Build image attributes
|
|
120
|
+
img_attributes = {
|
|
121
|
+
alt: alt,
|
|
122
|
+
loading: loading
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
# Add width and height if provided
|
|
126
|
+
img_attributes[:width] = width if width
|
|
127
|
+
img_attributes[:height] = height if height
|
|
128
|
+
|
|
129
|
+
# Add CSS class if provided
|
|
130
|
+
img_attributes[:class] = css_class if css_class
|
|
131
|
+
|
|
132
|
+
# Add data attributes if provided
|
|
133
|
+
data_attributes&.each do |key, value|
|
|
134
|
+
img_attributes[:"data-#{key}"] = value
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# Add any remaining options as HTML attributes
|
|
138
|
+
img_attributes.merge!(options)
|
|
139
|
+
|
|
140
|
+
# Generate responsive image attributes if enabled
|
|
141
|
+
if responsive && url_endpoint
|
|
142
|
+
responsive_options = Imagekitio::Models::GetImageAttributesOptions.new(
|
|
143
|
+
src: src,
|
|
144
|
+
url_endpoint: url_endpoint,
|
|
145
|
+
width: width&.to_i,
|
|
146
|
+
sizes: sizes,
|
|
147
|
+
transformation: transformation,
|
|
148
|
+
transformation_position: transformation_position&.to_sym,
|
|
149
|
+
query_parameters: query_parameters,
|
|
150
|
+
device_breakpoints: device_breakpoints,
|
|
151
|
+
image_breakpoints: image_breakpoints,
|
|
152
|
+
signed: signed,
|
|
153
|
+
expires_in: expires_in
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
responsive_attrs = helper.get_responsive_image_attributes(responsive_options)
|
|
157
|
+
|
|
158
|
+
# Use the generated attributes
|
|
159
|
+
img_attributes[:src] = responsive_attrs.src
|
|
160
|
+
img_attributes[:srcset] = responsive_attrs.src_set if responsive_attrs.src_set
|
|
161
|
+
# Use hash accessor to avoid type conversion error on nil values
|
|
162
|
+
sizes_value = responsive_attrs[:sizes]
|
|
163
|
+
img_attributes[:sizes] = sizes_value if sizes_value
|
|
164
|
+
else
|
|
165
|
+
# Non-responsive: just build a simple URL
|
|
166
|
+
src_options = Imagekitio::Models::SrcOptions.new(
|
|
167
|
+
src: src,
|
|
168
|
+
url_endpoint: url_endpoint,
|
|
169
|
+
transformation: transformation,
|
|
170
|
+
transformation_position: transformation_position&.to_sym,
|
|
171
|
+
query_parameters: query_parameters,
|
|
172
|
+
signed: signed,
|
|
173
|
+
expires_in: expires_in
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
img_attributes[:src] = helper.build_url(src_options)
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
# Generate the image tag
|
|
180
|
+
tag(:img, img_attributes)
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
# Generates a video tag with ImageKit URL transformations.
|
|
184
|
+
#
|
|
185
|
+
# @param src [String, ActiveStorage::Attached] Video path or Active Storage attachment
|
|
186
|
+
# @param options [Hash] Video tag options
|
|
187
|
+
#
|
|
188
|
+
# @option options [String] :url_endpoint ImageKit URL endpoint (overrides config)
|
|
189
|
+
# @option options [Array<Hash>] :transformation Array of transformation objects.
|
|
190
|
+
# See [Transformation docs](https://www.gemdocs.org/gems/imagekitio/4.0.0/Imagekitio/Models/Transformation.html) for available parameters
|
|
191
|
+
# @option options [Hash{Symbol=>String}] :query_parameters Additional query parameters
|
|
192
|
+
# @option options [Symbol] :transformation_position Position for transformations - `:path` or `:query` (default: `:query`)
|
|
193
|
+
# @option options [Boolean] :signed Whether to generate a signed URL (default: `false`)
|
|
194
|
+
# @option options [Integer, Float] :expires_in Expiration time in seconds for signed URLs
|
|
195
|
+
#
|
|
196
|
+
# @option options [Integer, String] :width Width attribute for the video tag
|
|
197
|
+
# @option options [Integer, String] :height Height attribute for the video tag
|
|
198
|
+
# @option options [String] :poster Poster image URL
|
|
199
|
+
# @option options [String] :preload Preload strategy - `"none"`, `"metadata"`, or `"auto"`
|
|
200
|
+
# @option options [Boolean] :controls Show video controls (default: `false`)
|
|
201
|
+
# @option options [Boolean] :autoplay Autoplay the video (default: `false`)
|
|
202
|
+
# @option options [Boolean] :loop Loop the video (default: `false`)
|
|
203
|
+
# @option options [Boolean] :muted Mute the video (default: `false`)
|
|
204
|
+
# @option options [String] :class CSS classes
|
|
205
|
+
# @option options [Hash] :data Data attributes
|
|
206
|
+
#
|
|
207
|
+
# @return [String] HTML video tag with ImageKit URL
|
|
208
|
+
#
|
|
209
|
+
# @see https://www.gemdocs.org/gems/imagekitio/4.0.0/Imagekitio/Models/SrcOptions.html SrcOptions model
|
|
210
|
+
# @see #ik_image_tag
|
|
211
|
+
#
|
|
212
|
+
# @example Basic usage
|
|
213
|
+
# ik_video_tag("/path/to/video.mp4", controls: true)
|
|
214
|
+
#
|
|
215
|
+
# @example With Active Storage
|
|
216
|
+
# ik_video_tag(post.video, controls: true)
|
|
217
|
+
#
|
|
218
|
+
# @example With transformations
|
|
219
|
+
# ik_video_tag(
|
|
220
|
+
# "/video.mp4",
|
|
221
|
+
# transformation: [{ width: 640, height: 480 }],
|
|
222
|
+
# controls: true
|
|
223
|
+
# )
|
|
224
|
+
#
|
|
225
|
+
# @example With poster image
|
|
226
|
+
# ik_video_tag(
|
|
227
|
+
# "/video.mp4",
|
|
228
|
+
# controls: true,
|
|
229
|
+
# poster: ik_url("/video.mp4/ik-thumbnail.jpg")
|
|
230
|
+
# )
|
|
231
|
+
def ik_video_tag(src, options = {})
|
|
232
|
+
# Handle Active Storage attachments
|
|
233
|
+
original_src = src
|
|
234
|
+
if active_storage_attachment?(src)
|
|
235
|
+
return nil unless src.attached?
|
|
236
|
+
|
|
237
|
+
original_src = src.blob.filename.to_s
|
|
238
|
+
src = src.blob.key
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
raise ArgumentError, 'src is required' if src.nil? || src.empty?
|
|
242
|
+
|
|
243
|
+
config = Imagekit::Rails.configuration
|
|
244
|
+
helper = config.client.helper
|
|
245
|
+
|
|
246
|
+
# Extract ImageKit-specific options
|
|
247
|
+
url_endpoint = options.delete(:url_endpoint) || config.url_endpoint
|
|
248
|
+
transformation = options.delete(:transformation) || []
|
|
249
|
+
query_parameters = options.delete(:query_parameters)
|
|
250
|
+
transformation_position = options.delete(:transformation_position) || config.transformation_position
|
|
251
|
+
signed = options.delete(:signed)
|
|
252
|
+
expires_in = options.delete(:expires_in)
|
|
253
|
+
|
|
254
|
+
# Extract HTML attributes
|
|
255
|
+
width = options.delete(:width)
|
|
256
|
+
height = options.delete(:height)
|
|
257
|
+
poster = options.delete(:poster)
|
|
258
|
+
preload = options.delete(:preload)
|
|
259
|
+
controls = options.delete(:controls)
|
|
260
|
+
autoplay = options.delete(:autoplay)
|
|
261
|
+
loop_video = options.delete(:loop)
|
|
262
|
+
muted = options.delete(:muted)
|
|
263
|
+
css_class = options.delete(:class)
|
|
264
|
+
data_attributes = options.delete(:data)
|
|
265
|
+
|
|
266
|
+
# Build video attributes
|
|
267
|
+
video_attributes = {}
|
|
268
|
+
|
|
269
|
+
# Add width and height if provided
|
|
270
|
+
video_attributes[:width] = width if width
|
|
271
|
+
video_attributes[:height] = height if height
|
|
272
|
+
|
|
273
|
+
# Add poster if provided
|
|
274
|
+
video_attributes[:poster] = poster if poster
|
|
275
|
+
|
|
276
|
+
# Add preload if provided
|
|
277
|
+
video_attributes[:preload] = preload if preload
|
|
278
|
+
|
|
279
|
+
# Add boolean attributes
|
|
280
|
+
video_attributes[:controls] = controls if controls
|
|
281
|
+
video_attributes[:autoplay] = autoplay if autoplay
|
|
282
|
+
video_attributes[:loop] = loop_video if loop_video
|
|
283
|
+
video_attributes[:muted] = muted if muted
|
|
284
|
+
|
|
285
|
+
# Add CSS class if provided
|
|
286
|
+
video_attributes[:class] = css_class if css_class
|
|
287
|
+
|
|
288
|
+
# Add data attributes if provided
|
|
289
|
+
data_attributes&.each do |key, value|
|
|
290
|
+
video_attributes[:"data-#{key}"] = value
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
# Add any remaining options as HTML attributes
|
|
294
|
+
video_attributes.merge!(options)
|
|
295
|
+
|
|
296
|
+
# Build video URL
|
|
297
|
+
src_options = Imagekitio::Models::SrcOptions.new(
|
|
298
|
+
src: src,
|
|
299
|
+
url_endpoint: url_endpoint,
|
|
300
|
+
transformation: transformation,
|
|
301
|
+
transformation_position: transformation_position&.to_sym,
|
|
302
|
+
query_parameters: query_parameters,
|
|
303
|
+
signed: signed,
|
|
304
|
+
expires_in: expires_in
|
|
305
|
+
)
|
|
306
|
+
|
|
307
|
+
video_url = helper.build_url(src_options)
|
|
308
|
+
|
|
309
|
+
# Determine file extension for video type
|
|
310
|
+
extension = if original_src == src
|
|
311
|
+
::File.extname(src).delete('.')
|
|
312
|
+
else
|
|
313
|
+
::File.extname(original_src).delete('.')
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
# Generate the video tag with source
|
|
317
|
+
content_tag(:video, video_attributes) do
|
|
318
|
+
tag(:source, src: video_url, type: "video/#{extension}")
|
|
319
|
+
end
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
private
|
|
323
|
+
|
|
324
|
+
# Check if the object is an Active Storage attachment.
|
|
325
|
+
#
|
|
326
|
+
# @api private
|
|
327
|
+
# @param obj [Object] Object to check
|
|
328
|
+
# @return [Boolean] `true` if object is an ActiveStorage::Attached::One instance
|
|
329
|
+
def active_storage_attachment?(obj)
|
|
330
|
+
return false unless defined?(::ActiveStorage)
|
|
331
|
+
return false unless defined?(::ActiveStorage::Attached)
|
|
332
|
+
return false unless defined?(::ActiveStorage::Attached::One)
|
|
333
|
+
|
|
334
|
+
obj.is_a?(::ActiveStorage::Attached::One)
|
|
335
|
+
end
|
|
336
|
+
end
|
|
337
|
+
end
|
|
338
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rails/railtie'
|
|
4
|
+
|
|
5
|
+
module Imagekit
|
|
6
|
+
module Rails
|
|
7
|
+
# Rails integration for ImageKit. Automatically includes view helpers and Active Storage callbacks.
|
|
8
|
+
# @private
|
|
9
|
+
class Railtie < ::Rails::Railtie
|
|
10
|
+
# Register view helpers
|
|
11
|
+
initializer 'imagekitio-rails.view_helpers' do
|
|
12
|
+
ActiveSupport.on_load(:action_view) do
|
|
13
|
+
include Imagekit::Rails::Helper
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
if defined?(ActiveStorage)
|
|
18
|
+
initializer 'imagekitio-rails.active_storage', after: 'active_storage.services' do
|
|
19
|
+
ActiveSupport.on_load(:active_storage_blob) do
|
|
20
|
+
include Imagekit::Rails::ActiveStorage::BlobDeletionCallback
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'imagekitio'
|
|
4
|
+
require_relative 'imagekit/rails/version'
|
|
5
|
+
require_relative 'imagekit/rails/configuration'
|
|
6
|
+
require_relative 'imagekit/rails/helper'
|
|
7
|
+
|
|
8
|
+
# Load Active Storage integration if ActiveStorage is available
|
|
9
|
+
if defined?(ActiveStorage)
|
|
10
|
+
require_relative 'imagekit/rails/active_storage'
|
|
11
|
+
require_relative 'imagekit/rails/active_storage/service'
|
|
12
|
+
require_relative 'imagekit/rails/active_storage/blob_deletion_callback'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
require_relative 'imagekit/rails/railtie' if defined?(Rails::Railtie)
|
|
16
|
+
|
|
17
|
+
# ImageKit Rails integration
|
|
18
|
+
#
|
|
19
|
+
# This is the top-level namespace for the ImageKit Ruby SDK. This gem (`imagekitio-rails`)
|
|
20
|
+
# provides Rails-specific integrations on top of the core SDK.
|
|
21
|
+
#
|
|
22
|
+
# ImageKit is a complete media management solution that provides:
|
|
23
|
+
# - Real-time image and video transformations (resize, crop, rotate, format conversion, etc.)
|
|
24
|
+
# - Intelligent optimization and compression
|
|
25
|
+
# - Fast content delivery via global CDN
|
|
26
|
+
# - Media storage and organization
|
|
27
|
+
# - URL-based transformations with caching
|
|
28
|
+
#
|
|
29
|
+
# @see Imagekit::Rails Rails integration
|
|
30
|
+
# @see https://imagekit.io ImageKit.io homepage
|
|
31
|
+
# @see https://github.com/imagekit-developer/imagekit-ruby ImageKit Ruby SDK
|
|
32
|
+
# @see https://imagekit.io/docs ImageKit documentation
|
|
33
|
+
module Imagekit
|
|
34
|
+
# Rails integration for ImageKit
|
|
35
|
+
#
|
|
36
|
+
# Provides seamless integration between Rails and ImageKit, including:
|
|
37
|
+
#
|
|
38
|
+
# **View Helpers:**
|
|
39
|
+
# - `ik_image_tag` - Generate `<img>` tags with ImageKit URLs, transformations, and responsive images
|
|
40
|
+
# - `ik_video_tag` - Generate `<video>` tags with ImageKit URLs and transformations
|
|
41
|
+
#
|
|
42
|
+
# **Active Storage Adapter:**
|
|
43
|
+
# - Store Rails Active Storage attachments directly in ImageKit
|
|
44
|
+
# - Automatic URL generation for stored files
|
|
45
|
+
# - Support for transformations on stored attachments
|
|
46
|
+
#
|
|
47
|
+
# **Configuration:**
|
|
48
|
+
# - Simple configuration via initializer or environment variables
|
|
49
|
+
# - Support for responsive images with customizable breakpoints
|
|
50
|
+
# - Flexible transformation positioning (query params or path-based)
|
|
51
|
+
#
|
|
52
|
+
# @example Configuration
|
|
53
|
+
# # config/initializers/imagekit.rb
|
|
54
|
+
# Imagekit::Rails.configure do |config|
|
|
55
|
+
# config.url_endpoint = ENV['IMAGEKIT_URL_ENDPOINT']
|
|
56
|
+
# config.public_key = ENV['IMAGEKIT_PUBLIC_KEY']
|
|
57
|
+
# config.private_key = ENV['IMAGEKIT_PRIVATE_KEY']
|
|
58
|
+
# end
|
|
59
|
+
#
|
|
60
|
+
# @example Using view helpers
|
|
61
|
+
# <%= ik_image_tag("/photo.jpg", transformation: [{ width: 400 }]) %>
|
|
62
|
+
# <%= ik_video_tag("/video.mp4", controls: true) %>
|
|
63
|
+
#
|
|
64
|
+
# @example Active Storage setup
|
|
65
|
+
# # config/storage.yml
|
|
66
|
+
# imagekit:
|
|
67
|
+
# service: ImageKit
|
|
68
|
+
#
|
|
69
|
+
# # app/models/user.rb
|
|
70
|
+
# class User < ApplicationRecord
|
|
71
|
+
# has_one_attached :avatar
|
|
72
|
+
# end
|
|
73
|
+
#
|
|
74
|
+
# # View
|
|
75
|
+
# <%= ik_image_tag(user.avatar, transformation: [{ width: 200, height: 200 }]) %>
|
|
76
|
+
#
|
|
77
|
+
# @see Imagekit::Rails::Helper View helpers documentation
|
|
78
|
+
# @see Imagekit::Rails::Configuration Configuration options
|
|
79
|
+
# @see Imagekit::Rails::ActiveStorage::Service Active Storage service
|
|
80
|
+
module Rails
|
|
81
|
+
# Standard error for ImageKit Rails gem
|
|
82
|
+
class Error < StandardError; end
|
|
83
|
+
end
|
|
84
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: imagekitio-rails
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0.beta.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- ImageKit
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2025-11-03 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: imagekitio
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '4.0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '4.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rails
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '6.0'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '6.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: redcarpet
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.6'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.6'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rspec
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '3.0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '3.0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rubocop
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '1.21'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '1.21'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: webrick
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '1.8'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '1.8'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: yard
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - "~>"
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0.9'
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - "~>"
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0.9'
|
|
111
|
+
description: Comprehensive Rails integration for ImageKit.io with view helpers (ik_image_tag,
|
|
112
|
+
ik_video_tag) and Active Storage service adapter. Provides easy image optimization,
|
|
113
|
+
transformation, and responsive image support.
|
|
114
|
+
email: support@imagekit.io
|
|
115
|
+
executables: []
|
|
116
|
+
extensions: []
|
|
117
|
+
extra_rdoc_files:
|
|
118
|
+
- README.md
|
|
119
|
+
files:
|
|
120
|
+
- CONTRIBUTING.md
|
|
121
|
+
- LICENSE
|
|
122
|
+
- README.md
|
|
123
|
+
- lib/active_storage/service/image_kit_service.rb
|
|
124
|
+
- lib/imagekit/rails/active_storage.rb
|
|
125
|
+
- lib/imagekit/rails/active_storage/blob_deletion_callback.rb
|
|
126
|
+
- lib/imagekit/rails/active_storage/service.rb
|
|
127
|
+
- lib/imagekit/rails/configuration.rb
|
|
128
|
+
- lib/imagekit/rails/helper.rb
|
|
129
|
+
- lib/imagekit/rails/railtie.rb
|
|
130
|
+
- lib/imagekit/rails/version.rb
|
|
131
|
+
- lib/imagekitio-rails.rb
|
|
132
|
+
homepage: https://github.com/imagekit-developer/imagekit-rails
|
|
133
|
+
licenses:
|
|
134
|
+
- Apache-2.0
|
|
135
|
+
metadata:
|
|
136
|
+
homepage_uri: https://github.com/imagekit-developer/imagekit-rails
|
|
137
|
+
source_code_uri: https://github.com/imagekit-developer/imagekit-rails
|
|
138
|
+
rubygems_mfa_required: 'false'
|
|
139
|
+
post_install_message:
|
|
140
|
+
rdoc_options: []
|
|
141
|
+
require_paths:
|
|
142
|
+
- lib
|
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
144
|
+
requirements:
|
|
145
|
+
- - ">="
|
|
146
|
+
- !ruby/object:Gem::Version
|
|
147
|
+
version: 3.2.0
|
|
148
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
|
+
requirements:
|
|
150
|
+
- - ">"
|
|
151
|
+
- !ruby/object:Gem::Version
|
|
152
|
+
version: 1.3.1
|
|
153
|
+
requirements: []
|
|
154
|
+
rubygems_version: 3.4.1
|
|
155
|
+
signing_key:
|
|
156
|
+
specification_version: 4
|
|
157
|
+
summary: ImageKit Rails integration with view helpers and Active Storage support
|
|
158
|
+
test_files: []
|