mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 06:49:14 +08:00
HELP NEEDED. Implement Me!
This commit is contained in:
parent
4d99dc035e
commit
6347cbe275
|
@ -1,15 +1,48 @@
|
|||
# This class is used to download an optimize images.
|
||||
# This class is used to download and optimize images.
|
||||
#
|
||||
# I have not had a chance to implement me, and will not for about 3 weeks.
|
||||
# If you are looking for a small project this simple API would be a good stint.
|
||||
#
|
||||
# Implement the following methods. With tests, the tests are a HUGE PITA cause
|
||||
# network, disk and external dependencies are involved.
|
||||
|
||||
class ImageOptimizer
|
||||
|
||||
def initialize(url)
|
||||
@url = url
|
||||
attr_accessor :url, :root_dir
|
||||
# url is a url of an image ex:
|
||||
# 'http://site.com/image.png'
|
||||
# '/uploads/site/image.png'
|
||||
#
|
||||
# root_dir is the path where we
|
||||
# store optimized images
|
||||
def initialize(opts = {})
|
||||
@url = opts[:url]
|
||||
@root_dir = opts[:root_dir]
|
||||
end
|
||||
|
||||
def force_refresh!
|
||||
# attempt to refresh the original image, if refreshed
|
||||
# remove old downsized copies
|
||||
def refresh_local!
|
||||
end
|
||||
|
||||
# clear all local copies of the images
|
||||
def clear_local!
|
||||
end
|
||||
|
||||
def optimized_path(width=nil, height=nil)
|
||||
|
||||
# yeild a list of relative paths to local images cached
|
||||
def each_local
|
||||
end
|
||||
|
||||
# return the path of an optimized image,
|
||||
# if already cached return cached, else download and cache
|
||||
# at the original size.
|
||||
# if size is specified return a resized image
|
||||
# if height or width are nil maintain aspect ratio
|
||||
#
|
||||
# Optimised image is the "most efficient" storage for an image
|
||||
# at the basic level it runs through image_optim https://github.com/toy/image_optim
|
||||
# it also has a failsafe that converts jpg to png or the opposite. if jpg size is 1.5*
|
||||
# as efficient as png it flips formats.
|
||||
def optimized_image_path(width=nil, height=nil)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user