@@ -127,12 +127,19 @@ public function add_features( $tag_element ) {
127127 * @return array
128128 */
129129 protected function apply_breakpoints ( $ tag_element ) {
130+ $ settings = $ this ->settings ->get_value ( 'media_display ' );
131+ $ max = $ settings ['max_width ' ];
132+ $ min = $ settings ['min_width ' ];
133+ $ width = (int ) $ tag_element ['width ' ];
134+ $ height = (int ) $ tag_element ['height ' ];
135+ $ debug_key = 'responsive_breakpoints_ ' . $ tag_element ['id ' ];
136+
137+ if ( ! $ width || ! $ height ) {
138+ // Translators: %s is the ID of the image missing width or height.
139+ Utils::log ( sprintf ( __ ( 'Missing width or height for image: %s ' , 'cloudinary ' ), $ tag_element ['id ' ] ), $ debug_key );
140+ return $ tag_element ;
141+ }
130142
131- $ settings = $ this ->settings ->get_value ( 'media_display ' );
132- $ max = $ settings ['max_width ' ];
133- $ min = $ settings ['min_width ' ];
134- $ width = $ tag_element ['width ' ];
135- $ height = $ tag_element ['height ' ];
136143 $ size_tag = '- ' . $ width . 'x ' . $ height . '. ' ;
137144 $ step = $ settings ['pixel_step ' ];
138145 $ ratio = $ width / $ height ;
@@ -159,6 +166,8 @@ protected function apply_breakpoints( $tag_element ) {
159166 $ tag_element ['atts ' ]['sizes ' ] = '(max-width: ' . $ width . 'px) 100vw, ' . $ width . 'px ' ;
160167 }
161168
169+ Utils::remove_log ( $ debug_key );
170+
162171 return $ tag_element ;
163172 }
164173
0 commit comments