Fix bugs when image width/height are null
This commit is contained in:
@@ -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,29 +508,31 @@ class Post < ActiveRecord::Base
|
|||||||
|
|
||||||
tags -= %w(incredibly_absurdres absurdres highres lowres huge_filesize)
|
tags -= %w(incredibly_absurdres absurdres highres lowres huge_filesize)
|
||||||
|
|
||||||
if image_width >= 10_000 || image_height >= 10_000
|
if has_dimensions?
|
||||||
tags << "incredibly_absurdres"
|
if image_width >= 10_000 || image_height >= 10_000
|
||||||
end
|
tags << "incredibly_absurdres"
|
||||||
if image_width >= 3200 || image_height >= 2400
|
end
|
||||||
tags << "absurdres"
|
if image_width >= 3200 || image_height >= 2400
|
||||||
end
|
tags << "absurdres"
|
||||||
if image_width >= 1600 || image_height >= 1200
|
end
|
||||||
tags << "highres"
|
if image_width >= 1600 || image_height >= 1200
|
||||||
end
|
tags << "highres"
|
||||||
if image_width <= 500 && image_height <= 500
|
end
|
||||||
tags << "lowres"
|
if image_width <= 500 && image_height <= 500
|
||||||
|
tags << "lowres"
|
||||||
|
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
|
end
|
||||||
|
|
||||||
if file_size >= 10.megabytes
|
if file_size >= 10.megabytes
|
||||||
tags << "huge_filesize"
|
tags << "huge_filesize"
|
||||||
end
|
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
|
|
||||||
|
|
||||||
return tags
|
return tags
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user