mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-03-28 03:34:22 -04:00
Cache photos
This commit is contained in:
committed by
Brenda Wallace
parent
4065b1b248
commit
d22fb68eee
@@ -1,14 +1,16 @@
|
||||
module PhotosHelper
|
||||
def crop_image_path(crop)
|
||||
if crop.default_photo.present?
|
||||
# The flickr thumbnails are too small, use full size
|
||||
if crop.default_photo.source == 'flickr'
|
||||
crop.default_photo.fullsize_url
|
||||
Rails.cache.fetch("crop_image_path/#{crop.id}") do
|
||||
if crop.default_photo.present?
|
||||
# The flickr thumbnails are too small, use full size
|
||||
if crop.default_photo.source == 'flickr'
|
||||
crop.default_photo.fullsize_url
|
||||
else
|
||||
crop.default_photo.thumbnail_url
|
||||
end
|
||||
else
|
||||
crop.default_photo.thumbnail_url
|
||||
placeholder_image
|
||||
end
|
||||
else
|
||||
placeholder_image
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -12,7 +12,9 @@ module PhotoCapable
|
||||
end
|
||||
|
||||
def most_liked_photo
|
||||
photos.order(likes_count: :desc, created_at: :desc).first
|
||||
Rails.cache.fetch("most_liked_photo/#{model_name}/#{id}") do
|
||||
photos.order(likes_count: :desc, created_at: :desc).first
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user