Class: C80News::Fphoto
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- C80News::Fphoto
- Defined in:
- app/models/c80_news/fphoto.rb
Instance Method Summary collapse
-
#content_image(type = 'normal') ⇒ Object
в ~ от размеров thumb-ов и page_content_width - выдать соответствующую картинку • Если у картинки thumb_big шириной ≥ page_content_width - вставляем этот thumb_big.
-
#content_image_size(type = 'normal') ⇒ Object
выдать размеры картинки, которая будет вставлена в текст страницы.
-
#thumb_preview_size ⇒ Object
выдать размеры картинки thumb_preview.
Instance Method Details
#content_image(type = 'normal') ⇒ Object
в ~ от размеров thumb-ов и page_content_width - выдать соответствующую картинку • Если у картинки thumb_big шириной ≥ page_content_width - вставляем этот thumb_big. • Иначе: вставлем thumb_small.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/models/c80_news/fphoto.rb', line 15 def content_image(type='normal') if type == 'normal' img = MiniMagick::Image.open(image.thumb_big.path) w = SiteProp.first.page_content_width if img["width"] < w image.thumb_small else image.thumb_big end elsif type == 'small' image.thumb_small elsif type == 'big' image.thumb_big end end |
#content_image_size(type = 'normal') ⇒ Object
выдать размеры картинки, которая будет вставлена в текст страницы
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/models/c80_news/fphoto.rb', line 36 def content_image_size(type='normal') if type == 'normal' img = MiniMagick::Image.open(image.thumb_big.path) w = SiteProp.first.page_content_width if img["width"] < w img = MiniMagick::Image.open(image.thumb_small.path) [img["width"],img["height"]] else [img["width"],img["height"]] end elsif type == 'small' img = MiniMagick::Image.open(image.thumb_small.path) [img["width"],img["height"]] elsif type == 'big' img = MiniMagick::Image.open(image.thumb_big.path) [img["width"],img["height"]] end end |
#thumb_preview_size ⇒ Object
выдать размеры картинки thumb_preview
59 60 61 62 |
# File 'app/models/c80_news/fphoto.rb', line 59 def thumb_preview_size img = MiniMagick::Image.open(image.thumb_preview.path) [img["width"],img["height"]] end |