Module: PlainRecord::Extra::Image::Model
- Defined in:
- lib/plain_record/extra/image.rb
Instance Attribute Summary collapse
-
#image_sizes ⇒ Object
Hash of image sizes.
Instance Method Summary collapse
-
#get_image_file(entry, field, size) ⇒ Object
Get converted image path.
-
#get_image_from(entry, field) ⇒ Object
Get source image path.
-
#get_image_url(entry, field, size) ⇒ Object
Get relative image URL path.
-
#image_from(&block) ⇒ Object
Set source image path.
-
#image_url(&block) ⇒ Object
Set relative image URL path from
image_base
.
Instance Attribute Details
#image_sizes ⇒ Object
Hash of image sizes.
199 200 201 |
# File 'lib/plain_record/extra/image.rb', line 199 def image_sizes @image_sizes end |
Instance Method Details
#get_image_file(entry, field, size) ⇒ Object
Get converted image path.
217 218 219 220 221 222 223 |
# File 'lib/plain_record/extra/image.rb', line 217 def get_image_file(entry, field, size) unless @image_url raise ArgumentError, "You need to set `image_url` in #{to_s} to calculate file path." end File.join(Image.dir, @image_url.call(entry, field, size)) end |
#get_image_from(entry, field) ⇒ Object
Get source image path.
212 213 214 |
# File 'lib/plain_record/extra/image.rb', line 212 def get_image_from(entry, field) PlainRecord.root(@image_from.call(entry, field)) end |
#get_image_url(entry, field, size) ⇒ Object
Get relative image URL path.
226 227 228 229 230 231 232 |
# File 'lib/plain_record/extra/image.rb', line 226 def get_image_url(entry, field, size) unless @image_url raise ArgumentError, "You need to set `image_url` in #{to_s} to calculate file path." end File.join(Image.url, @image_url.call(entry, field, size)) end |
#image_from(&block) ⇒ Object
Set source image path.
202 203 204 |
# File 'lib/plain_record/extra/image.rb', line 202 def image_from(&block) @image_from = block end |
#image_url(&block) ⇒ Object
Set relative image URL path from image_base
.
207 208 209 |
# File 'lib/plain_record/extra/image.rb', line 207 def image_url(&block) @image_url = block end |