Class: C80NewsTz::RBphoto

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/c80_news_tz/r_bphoto.rb

Instance Method Summary collapse

Instance Method Details

#content_imageObject

в ~ от размеров thumb-ов и page_content_width - выдать соответствующую картинку • Если у картинки thumb_big шириной ≥ page_content_width - вставляем этот thumb_big. • Иначе: вставлем thumb_small.



10
11
12
13
14
15
16
17
18
# File 'app/models/c80_news_tz/r_bphoto.rb', line 10

def content_image
  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
end

#content_image_sizeObject

выдать размеры картинки, которая будет вставлена в текст страницы



21
22
23
24
25
26
27
28
29
30
# File 'app/models/c80_news_tz/r_bphoto.rb', line 21

def content_image_size
  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
end