@@ -131,9 +131,8 @@ private function generateCssFromImages(string $elementClass, array $images) : st
131
131
'background-image ' => 'url( ' . $ images ['desktop_image ' ] . ') ' ,
132
132
];
133
133
}
134
- if (isset ($ images ['mobile_image ' ]) && $ this ->getMobileBreakpoint ()) {
135
- $ mediaQuery = '@media only screen and (max-width: ' . $ this ->getMobileBreakpoint () . ') ' ;
136
- $ css [$ mediaQuery ]['. ' . $ elementClass ] = [
134
+ if (isset ($ images ['mobile_image ' ]) && $ this ->getMobileMediaQuery ()) {
135
+ $ css [$ this ->getMobileMediaQuery ()]['. ' . $ elementClass ] = [
137
136
'background-image ' => 'url( ' . $ images ['mobile_image ' ] . ') ' ,
138
137
];
139
138
}
@@ -163,13 +162,23 @@ private function cssFromArray(array $css) : string
163
162
}
164
163
165
164
/**
166
- * Retrieve the mobile breakpoint from the view configuration
165
+ * Generate the mobile media query from view configuration
167
166
*
168
167
* @return null|string
169
168
*/
170
- private function getMobileBreakpoint () : ?string
169
+ private function getMobileMediaQuery () : ?string
171
170
{
172
- $ breakpoints = $ this ->viewConfig ->getViewConfig ()->getVarValue ('Magento_PageBuilder ' , 'breakpoints ' );
173
- return isset ($ breakpoints ['mobile ' ]) ? $ breakpoints ['mobile ' ] : null ;
171
+ $ breakpoints = $ this ->viewConfig ->getViewConfig ()->getVarValue (
172
+ 'Magento_PageBuilder ' ,
173
+ 'breakpoints/mobile/conditions '
174
+ );
175
+ if ($ breakpoints && count ($ breakpoints ) > 0 ) {
176
+ $ mobileBreakpoint = "@media only screen " ;
177
+ foreach ($ breakpoints as $ key => $ value ) {
178
+ $ mobileBreakpoint .= "and ( " . $ key . ": " . $ value . ") " ;
179
+ }
180
+ return rtrim ($ mobileBreakpoint );
181
+ }
182
+ return null ;
174
183
}
175
184
}
0 commit comments