Support WEBP images again

We introduced a list of formats we support and forgot to add webp. Now I
added that as allowed format again and modified the error message.

I removed the first sentence from the error message because it's very
similar to the default error which is shown as well.
This commit is contained in:
Maikel Linke
2022-07-22 11:24:45 +10:00
parent 4766c7a00b
commit b419f063dc
5 changed files with 8 additions and 8 deletions

View File

@@ -84,8 +84,8 @@ class Enterprise < ApplicationRecord
has_one_attached :promo_image
has_one_attached :terms_and_conditions
validates :logo, content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml)\Z}
validates :promo_image, content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml)\Z}
validates :logo, content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
validates :promo_image, content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
validates :terms_and_conditions, content_type: {
in: "application/pdf",
message: I18n.t(:enterprise_terms_and_conditions_type_error),

View File

@@ -28,8 +28,8 @@ class EnterpriseGroup < ApplicationRecord
has_one_attached :logo
has_one_attached :promo_image
validates :logo, content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml)\Z}
validates :promo_image, content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml)\Z}
validates :logo, content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
validates :promo_image, content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
scope :by_position, -> { order('position ASC') }
scope :on_front_page, -> { where(on_front_page: true) }

View File

@@ -11,7 +11,7 @@ module Spree
has_one_attached :attachment
validates :attachment, attached: true, content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml)\Z}
validates :attachment, attached: true, content_type: %r{\Aimage/(png|jpeg|gif|jpg|svg\+xml|webp)\Z}
validate :no_attachment_errors
def variant(name)

View File

@@ -3926,7 +3926,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using
paypal:
no_payment_via_admin_backend: Paypal payments cannot be captured in the Backoffice
products:
image_upload_error: "The product image was not recognised. Please upload an image in PNG or JPG format."
image_upload_error: "Please upload the image in JPG, PNG, GIF, SVG or WEBP format."
new:
title: "New Product"
new_product: "New Product"

View File

@@ -590,8 +590,8 @@ describe '
attach_file('image_attachment', unsupported_image_file_path)
click_button "Create"
expect(page).to have_text "The product image was not recognised."
expect(page).to have_text "Please upload an image in PNG or JPG format."
expect(page).to have_text "Attachment has an invalid content type"
expect(page).to have_text "Please upload the image in JPG, PNG, GIF, SVG or WEBP format."
end
it "deleting product images", js: true do