Class: Spree::Image
Defined Under Namespace
Modules: Configuration
Instance Method Summary
collapse
Methods inherited from Base
belongs_to_required_by_default, page, spree_base_scopes
#clear_preferences, #default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference
Instance Method Details
#plp_url ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'app/models/spree/image.rb', line 61
def plp_url
size = self.class.styles[:plp_and_carousel]
variant = attachment.variant(
gravity: 'center',
resize: size,
extent: size,
background: 'snow2',
quality: 80
)
polymorphic_path(variant, only_path: true)
end
|
#style(name) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'app/models/spree/image.rb', line 31
def style(name)
size = self.class.styles[name]
return unless size
width, height = size.chop.split('x')
{
url: polymorphic_path(attachment.variant(combine_options: {
gravity: 'center',
resize: size,
extent: size,
background: 'snow2',
quality: 80
}), only_path: true),
size: size,
width: width,
height: height
}
end
|
#style_dimensions(name) ⇒ Object
51
52
53
54
55
56
57
58
59
|
# File 'app/models/spree/image.rb', line 51
def style_dimensions(name)
size = self.class.styles[name]
width, height = size.chop.split('x')
{
width: width,
height: height
}
end
|
#styles ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'app/models/spree/image.rb', line 13
def styles
self.class.styles.map do |_, size|
width, height = size.chop.split('x')
{
url: polymorphic_path(attachment.variant(combine_options: {
gravity: 'center',
resize: size,
extent: size,
background: 'snow2',
quality: 80
}), only_path: true),
width: width,
height: height
}
end
end
|