fixed image resizing
This commit is contained in:
@@ -1,16 +1,23 @@
|
||||
module PostsHelper
|
||||
def resize_image_links(post, user)
|
||||
links = []
|
||||
|
||||
if post.has_medium?
|
||||
links << link_to("M", post.medium_file_url, :id => "medium-file-link")
|
||||
end
|
||||
|
||||
links << %{<a href="#" data-src="#{post.file_url}" data-width="#{post.image_width}" data-height="#{post.image_height}">Original</a>} if post.has_medium? || post.has_large?
|
||||
links << %{<a href="#" data-src="#{post.medium_file_url}" data-width="#{post.medium_image_width}" data-height="#{post.medium_image_height}">Medium</a>} if post.has_medium?
|
||||
links << %{<a href="#" data-src="#{post.large_file_url}" data-width="#{post.large_image_width}" data-height="#{post.large_image_height}">Large</a>} if post.has_large?
|
||||
if post.has_large?
|
||||
links << link_to("L", post.large_file_url, :id => "large-file-link")
|
||||
end
|
||||
|
||||
if post.has_medium? || post.has_large?
|
||||
links << link_to("O", post.file_url, :id => "original-file-link")
|
||||
end
|
||||
|
||||
if links.any?
|
||||
html = %{<li id="resize-link"><a href="#">Resize</a></li><ul id="resize-links">} + links.map {|x| %{<li>#{x}</li>}}.join("") + %{</ul>}
|
||||
html.html_safe
|
||||
content_tag("span", raw("Resize: " + links.join(" ")))
|
||||
else
|
||||
""
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user