-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not able to change images size #3700
Comments
Hi, any idea? @kennyadsl |
It doesn't seem to work any longer with Rails 6 / Zeitwerk in an initializer.
For more details about Decorations: https://guides.solidus.io/developers/customizations/decorators.html With Rails 5.2 it works fine @kennyadsl i am not sure how to make it work again in Zeitwerk. Maybe you can suggest something? |
I think it's a filename issue. Where this |
The Image Decorator would be a workaround. Normally
should work in an initializer like stated here Product images which seems not to work in rails 6 |
Oh, you are right. This seems like a bug then, I'll try to take a look asap. |
There is another workaround You are able to set your own |
Given that this issue has been open for a while, I decided to verify if the bug still exists. Below I have described my findings: To update the Spree.config do |config|
...
config.product_image_styles = {
mini: '48x48>',
small: '100x100>',
product: '240x240>',
large: '600x600>'
}
...
end This configuration option is used in solidus/core/app/models/spree/image/active_storage_attachment.rb Lines 14 to 16 in cc56661
The method solidus/core/app/models/concerns/spree/active_storage_adapter.rb Lines 32 to 46 in 3ba6bc6
Therefore by using the configuration snippet above you are able to customize the attachment styles, therefore there is no longer a need to override or patch the Both the developer guides and edgeguides still recommend using the following snippets: # From the developer guides
Spree::Image.attachment_definitions[:attachment][:styles] = {
mini: '48x48>',
small: '100x100>',
product: '240x240>',
large: '600x600>'
} # From the EdgeGuides
module AmazingStore
module Spree
module Image
module CustomizeSizes
def self.prepended(klass)
klass.attachment_definitions[:attachment][:styles] = {
mini: '48x48>',
small: '400x400>',
product: '680x680>',
large: '1200x1200>',
jumbo: '1600x1600>'
}
end
::Spree::Image.prepend self
end
end
end
end As this is outdated, I recommend we use this issue to create a PR that updates the documentation accordingly, and adds some tests such that we verify this behaviour (I wasn't able to find any existing tests). Once merged, I believe we can close this issue. I will take a look at doing this tomorrow. What about the PaperclipAttachment?When the solidus/core/app/models/spree/image/paperclip_attachment.rb Lines 9 to 15 in cc56661
This is a method defined by |
I like the plan, when documenting this, please be aware that not all the Solidus versions support ActiveStorage (I think it has been introduced in 2.11), so we should reflect that in the documentation. Thanks! |
I am trying to change sizes with this in the initializer:
Spree::Image.attachment_definitions[:attachment][:styles] = {
mini: '48x48>',
small: '100x100>',
product: '240x240>',
large: '600x600>'
}
But 'module Spree::Image::ActiveStorageAttachment' don't take new sizes. How to do it?
Solidus Version:
Last version of master
To Reproduce
The text was updated successfully, but these errors were encountered: