-
-
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
Add #gallery
to Spree::Variant
and Spree::Product
#2323
Add #gallery
to Spree::Variant
and Spree::Product
#2323
Conversation
This wraps the `has_many :images` association of Variants. If we decide to change the implementation of images on variants (or get rid of them completely) this will keep the API from breaking.
This wraps the collection of images that a product gets from its variants. If we decide to change the implementation of images on products (or remove them completely) this will keep the API from breaking.
Uses `Product#gallery`. The thumbnails for products no longer include the master variant's images. Showing a thumbnail for the master variant doesn't make sense since that variant isn't something that a user can elect to buy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some files could not be reviewed due to errors:
.rubocop.yml: Style/FileName has the wrong namespace - should be Naming
.rubocop.yml: Style/FileName has the wrong namespace - should be Naming .rubocop.yml: Style/PredicateName has the wrong namespace - should be Naming .rubocop.yml: Style/AccessorMethodName has the wrong namespace - should be Naming .rubocop.yml: Style/VariableNumber has the wrong namespace - should be Naming Error: The `Style/OpMethod` cop has been renamed and moved to `Naming/BinaryOperatorParameterName`. (obsolete configuration found in .rubocop.yml, please update it)
@@ -1,19 +1,10 @@ | |||
<%# no need for thumbnails unless there is more than one image %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't change the behaviour of this file. We can't have it so users upgrade and the logic for displaying images on the frontend changes (I think it's likely in a ton of stores that this wouldn't be caught before production).
# | ||
# @return [Enumerable] of media for a variant | ||
def gallery | ||
Variant.reflect_on_association(:images) ? association(:images).reader : [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We define this association, so we shouldn't test for it. If this is to prepare for a future paperclip removal PR, it should be done later.
# | ||
# @return [Enumerable] of media for a product (and its variants) | ||
def gallery | ||
if Product.method_defined?(:variant_images) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We define this association, so we shouldn't test for it. If this is to prepare for a future paperclip removal PR, it should be done later.
Closed in favour of #2337 |
This is a lightweight version of #625.
Related to #2324, I think this is a good starting point to begin opening up an interface for different image upload implementations.