diff --git a/app/models/article.rb b/app/models/article.rb index cac851160b0..45125df5a2d 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -31,7 +31,7 @@ class Article < ApplicationRecord validates :thumbnail_type, presence: true validates :published_at, presence: true, if: :will_be_published? validates :thumbnail, - content_type: %w[image/png image/jpg image/jpeg], + content_type: %w[image/png image/jpeg], size: { less_than: 10.megabytes } paginates_per 24 diff --git a/app/models/book.rb b/app/models/book.rb index 797c0002f7c..8b7bc4fd8a9 100644 --- a/app/models/book.rb +++ b/app/models/book.rb @@ -11,7 +11,7 @@ class Book < ApplicationRecord validates :price, presence: true, numericality: { only_integer: true } validates :page_url, presence: true validates :cover, - content_type: %w[image/png image/jpg image/jpeg], + content_type: %w[image/png image/jpeg], size: { less_than: 10.megabytes } def cover_url diff --git a/app/models/user.rb b/app/models/user.rb index a8cd9f26448..d600e2e9d80 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -882,7 +882,7 @@ def validate_uploaded_avatar_content_type return unless uploaded_avatar mime_type = Marcel::Magic.by_magic(uploaded_avatar)&.type - return if mime_type&.start_with?('image/png', 'image/jpg', 'image/jpeg', 'image/gif', 'image/heic', 'image/heif') + return if mime_type&.start_with?('image/png', 'image/jpeg', 'image/gif', 'image/heic', 'image/heif') errors.add(:avatar, 'は指定された拡張子(PNG, JPG, JPEG, GIF, HEIC, HEIF形式)になっていないか、あるいは画像が破損している可能性があります') end diff --git a/app/models/work.rb b/app/models/work.rb index 6708f0a152a..cc88313f926 100644 --- a/app/models/work.rb +++ b/app/models/work.rb @@ -18,7 +18,7 @@ class Work < ApplicationRecord message: 'は「http://example.com」や「https://example.com」のようなURL形式で入力してください' } validates :thumbnail, - content_type: %w[image/png image/jpg image/jpeg], + content_type: %w[image/png image/jpeg], size: { less_than: 10.megabytes } def thumbnail_url