{"record":{"id":"350e629422e35159","repo":"spree/spree","slug":"spree-variant-additional-images-is-deprecated-and","errorCode":null,"errorMessage":"Spree::Variant#additional_images is deprecated and will be removed in Spree 6.1. Use #gallery_media instead.","messagePattern":"Spree::Variant#additional_images is deprecated and will be removed in Spree 6\\.1\\. Use #gallery_media instead\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"spree/core/app/models/spree/variant.rb","lineNumber":474,"sourceCode":"\n      update_column(:primary_media_id, first_media&.id)\n    end\n\n    # @deprecated Read #gallery_media directly; removed in 6.1. Nothing in\n    #   Spree calls this — a hover image is a storefront presentation choice,\n    #   not something core should name.\n    # @return [Spree::Media, nil]\n    def secondary_image\n      Spree::Deprecation.warn('Spree::Variant#secondary_image is deprecated and will be removed in Spree 6.1. Use #gallery_media instead.')\n      gallery_media.second\n    end\n\n    # @deprecated Read #gallery_media directly; removed in 6.1. Nothing in\n    #   Spree calls this, and which images to show beside the main one is a\n    #   storefront presentation choice.\n    # @return [Array<Spree::Media>]\n    def additional_images\n      Spree::Deprecation.warn('Spree::Variant#additional_images is deprecated and will be removed in Spree 6.1. Use #gallery_media instead.')\n      gallery_media.reject { |media| media.id == primary_media&.id }\n    end\n\n    # Returns an array of hashes with the option type name, value and presentation\n    # @return [Array<Hash>]\n    def options\n      @options ||= option_values.\n                   includes(option_type: :product_option_types).\n                   merge(product.product_option_types).\n                   reorder('spree_product_option_types.position').\n                   map do |option_value|\n                     {\n                       name: option_value.option_type.name,\n                       value: option_value.name,\n                       presentation: option_value.presentation\n                     }\n                   end\n    end","sourceCodeStart":456,"sourceCodeEnd":492,"githubUrl":"https://github.com/spree/spree/blob/06bf66a8684b9de03210bbb2ddc8c1f5ba522fa2/spree/core/app/models/spree/variant.rb#L456-L492","documentation":"Variant#additional_images returned the gallery minus the primary image for thumbnail strips. 6.0 drops it as a presentation concern — the deprecated shell delegates to gallery_media.reject { |m| m.id == primary_media&.id }, warns per call, and is removed in 6.1. Nothing in Spree calls it.","triggerScenarios":"Storefront gallery partials calling variant.additional_images to render thumbnails beside the main image.","commonSituations":"Themes and gallery components written for Spree 5.x; code that assumed the exclusion rule (primary excluded) lives in core.","solutions":["Compute it in your view/presenter: variant.gallery_media.reject { |m| m.id == variant.primary_media&.id }.","Or simply iterate variant.gallery_media and skip the primary in the template — own the exclusion rule.","Cache the reject in a local variable when used multiple times per card.","Update theme gems to Spree 6-compatible releases."],"exampleFix":"# before\nvariant.additional_images.each { |image| ... }\n\n# after\nvariant.gallery_media.reject { |m| m.id == variant.primary_media&.id }.each { |image| ... }","handlingStrategy":"fallback","validationCode":"thumbs = if variant.respond_to?(:gallery_media)\n  variant.gallery_media.reject { |m| m.id == variant.primary_media&.id }\nelse\n  variant.additional_images\nend","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the primary-exclusion rule in one presenter/helper you own so core renames cannot fragment it.","Compute the reject once per render, not per thumbnail.","Cover gallery partials with view specs run under raise-on-deprecation."],"tags":["spree","deprecation","variant","media","gallery","storefront"],"backgroundTag":"deprecated-method-rename","analyzedSha":"06bf66a8684b9de03210bbb2ddc8c1f5ba522fa2","analyzedAt":"2026-08-21T14:59:48.125Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}