Fix bugs when image width/height are null

This commit is contained in:
Toks
2014-08-02 17:07:55 -04:00
parent 58f4d477f5
commit 993094edf1

View File

@@ -137,7 +137,7 @@ class Post < ActiveRecord::Base
end end
def has_dimensions? def has_dimensions?
is_image? || is_flash? || is_video? image_width.present? && image_height.present?
end end
end end
@@ -508,6 +508,7 @@ class Post < ActiveRecord::Base
tags -= %w(incredibly_absurdres absurdres highres lowres huge_filesize) tags -= %w(incredibly_absurdres absurdres highres lowres huge_filesize)
if has_dimensions?
if image_width >= 10_000 || image_height >= 10_000 if image_width >= 10_000 || image_height >= 10_000
tags << "incredibly_absurdres" tags << "incredibly_absurdres"
end end
@@ -521,15 +522,16 @@ class Post < ActiveRecord::Base
tags << "lowres" tags << "lowres"
end end
if file_size >= 10.megabytes
tags << "huge_filesize"
end
if image_width >= 1024 && image_width.to_f / image_height >= 4 if image_width >= 1024 && image_width.to_f / image_height >= 4
tags << "wide_image long_image" tags << "wide_image long_image"
elsif image_height >= 1024 && image_height.to_f / image_width >= 4 elsif image_height >= 1024 && image_height.to_f / image_width >= 4
tags << "tall_image long_image" tags << "tall_image long_image"
end end
end
if file_size >= 10.megabytes
tags << "huge_filesize"
end
return tags return tags
end end