Class: Spree::Image
Defined Under Namespace
Modules: Configuration
Instance Method Summary
collapse
#generate_url, #original_url
Methods inherited from Base
belongs_to_required_by_default, for_store, has_many_inversing, json_api_columns, json_api_permitted_attributes, json_api_type, page, spree_base_scopes, spree_base_uniqueness_scope
#clear_preferences, #default_preferences, #defined_preferences, #deprecated_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_deprecated, #preference_type, #set_preference
Instance Method Details
#plp_url ⇒ Object
51
52
53
|
# File 'app/models/spree/image.rb', line 51
def plp_url
generate_url(size: self.class.styles[:plp_and_carousel])
end
|
#style(name) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'app/models/spree/image.rb', line 27
def style(name)
size = self.class.styles[name]
return unless size
width, height = size.chop.split('x').map(&:to_i)
{
url: generate_url(size: size),
size: size,
width: width,
height: height
}
end
|
#style_dimensions(name) ⇒ Object
41
42
43
44
45
46
47
48
49
|
# File 'app/models/spree/image.rb', line 41
def style_dimensions(name)
size = self.class.styles[name]
width, height = size.chop.split('x').map(&:to_i)
{
width: width,
height: height
}
end
|
#styles ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'app/models/spree/image.rb', line 14
def styles
self.class.styles.map do |_, size|
width, height = size.chop.split('x').map(&:to_i)
{
url: generate_url(size: size),
size: size,
width: width,
height: height
}
end
end
|