@@ -122,14 +122,13 @@ function get_param_definitions( $params )
122122 'size_begin_line ' => array (
123123 'type ' => 'begin_line ' ,
124124 'label ' => T_ ('Image size ' ),
125+ 'note ' => T_ ('Leave blank for auto. ' ),
125126 ),
126127 'width ' => array (
127- 'label ' => T_ ('Image width ' ),
128128 'note ' => '' ,
129129 'defaultvalue ' => '' ,
130130 'allow_empty ' => true ,
131131 'size ' => 4 ,
132- 'hide_label ' => true ,
133132 'valid_pattern ' => array (
134133 'pattern ' => '~^(\d+(px|%)?)?$~i ' ,
135134 'error ' => sprintf ( T_ ('Invalid image size, it must be specified in px or %%. ' ) ) ),
@@ -139,19 +138,45 @@ function get_param_definitions( $params )
139138 'type ' => 'string ' ,
140139 ),
141140 'height ' => array (
142- 'label ' => T_ ('Image height ' ),
143- 'note ' => '' ,
141+ 'note ' => T_ ('Leave blank for auto. ' ),
144142 'defaultvalue ' => '' ,
145143 'allow_empty ' => true ,
146144 'size ' => 4 ,
147- 'hide_label ' => true ,
148145 'valid_pattern ' => array (
149146 'pattern ' => '~^(\d+(px|%)?)?$~i ' ,
150147 'error ' => sprintf ( T_ ('Invalid image size, it must be specified in px or %%. ' ) ) ),
151148 ),
152149 'size_end_line ' => array (
153150 'type ' => 'end_line ' ,
154- 'label ' => T_ ('Leave blank for auto. ' ),
151+ ),
152+ 'max_size_begin_line ' => array (
153+ 'type ' => 'begin_line ' ,
154+ 'label ' => T_ ('Max size ' ),
155+ ),
156+ 'max_width ' => array (
157+ 'note ' => '' ,
158+ 'defaultvalue ' => '' ,
159+ 'allow_empty ' => true ,
160+ 'size ' => 4 ,
161+ 'valid_pattern ' => array (
162+ 'pattern ' => '~^(\d+(px|%)?)?$~i ' ,
163+ 'error ' => sprintf ( T_ ('Invalid max size, it must be specified in px or %%. ' ) ) ),
164+ ),
165+ 'max_size_separator ' => array (
166+ 'label ' => ' x ' ,
167+ 'type ' => 'string ' ,
168+ ),
169+ 'max_height ' => array (
170+ 'note ' => T_ ('Leave blank for auto. ' ),
171+ 'defaultvalue ' => '' ,
172+ 'allow_empty ' => true ,
173+ 'size ' => 4 ,
174+ 'valid_pattern ' => array (
175+ 'pattern ' => '~^(\d+(px|%)?)?$~i ' ,
176+ 'error ' => sprintf ( T_ ('Invalid max size, it must be specified in px or %%. ' ) ) ),
177+ ),
178+ 'max_size_end_line ' => array (
179+ 'type ' => 'end_line ' ,
155180 ),
156181 'alt ' => array (
157182 'label ' => T_ ('Image Alt text ' ),
@@ -243,9 +268,18 @@ function display( $params )
243268 );
244269
245270 // Initialize image attributes:
271+ // Image width:
246272 $ image_attrs ['style ' ] = 'width: ' .( empty ( $ this ->disp_params ['width ' ] ) ? 'auto ' : format_to_output ( $ this ->disp_params ['width ' ], 'htmlattr ' ) ).'; ' ;
247273 // Image height:
248274 $ image_attrs ['style ' ] .= 'height: ' .( empty ( $ this ->disp_params ['height ' ] ) ? 'auto ' : format_to_output ( $ this ->disp_params ['height ' ], 'htmlattr ' ) ).'; ' ;
275+ if ( ! empty ( $ this ->disp_params ['max_width ' ] ) )
276+ { // Max width:
277+ $ image_attrs ['style ' ] .= 'max-width: ' .format_to_output ( $ this ->disp_params ['max_width ' ], 'htmlattr ' ).'; ' ;
278+ }
279+ if ( ! empty ( $ this ->disp_params ['max_height ' ] ) )
280+ { // Max height:
281+ $ image_attrs ['style ' ] .= 'max-height: ' .format_to_output ( $ this ->disp_params ['max_height ' ], 'htmlattr ' ).'; ' ;
282+ }
249283 // If no unit is specified in a size, consider the unit to be px:
250284 $ image_attrs ['style ' ] = preg_replace ( '/(\d+);/ ' , '$1px; ' , $ image_attrs ['style ' ] );
251285
0 commit comments