Fix bugs when image width/height are null
This commit is contained in:
@@ -137,7 +137,7 @@ class Post < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def has_dimensions?
|
||||
is_image? || is_flash? || is_video?
|
||||
image_width.present? && image_height.present?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -508,6 +508,7 @@ class Post < ActiveRecord::Base
|
||||
|
||||
tags -= %w(incredibly_absurdres absurdres highres lowres huge_filesize)
|
||||
|
||||
if has_dimensions?
|
||||
if image_width >= 10_000 || image_height >= 10_000
|
||||
tags << "incredibly_absurdres"
|
||||
end
|
||||
@@ -521,15 +522,16 @@ class Post < ActiveRecord::Base
|
||||
tags << "lowres"
|
||||
end
|
||||
|
||||
if file_size >= 10.megabytes
|
||||
tags << "huge_filesize"
|
||||
end
|
||||
|
||||
if image_width >= 1024 && image_width.to_f / image_height >= 4
|
||||
tags << "wide_image long_image"
|
||||
elsif image_height >= 1024 && image_height.to_f / image_width >= 4
|
||||
tags << "tall_image long_image"
|
||||
end
|
||||
end
|
||||
|
||||
if file_size >= 10.megabytes
|
||||
tags << "huge_filesize"
|
||||
end
|
||||
|
||||
return tags
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user