Skip to content

Commit 0ba45bb

Browse files
committed
New setting "Max size" for widget "Image"
1 parent 1c035ca commit 0ba45bb

4 files changed

Lines changed: 43 additions & 11 deletions

File tree

conf/_application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* Release date (ISO)
2222
* @global string
2323
*/
24-
$app_date = '2020-06-24';
24+
$app_date = '2020-06-25';
2525

2626
/**
2727
* Is this b2evolution PRO?

inc/widgets/widgets/_coll_logo.widget.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ function get_param_definitions( $params )
140140
),
141141
'height' => array(
142142
'label' => T_('Image height'),
143-
'note' => '',
143+
'note' => T_('Leave blank for auto.'),
144144
'defaultvalue' => '',
145145
'allow_empty' => true,
146146
'size' => 4,
@@ -151,7 +151,6 @@ function get_param_definitions( $params )
151151
),
152152
'size_end_line' => array(
153153
'type' => 'end_line',
154-
'label' => T_('Leave blank for auto.'),
155154
),
156155
'alt' => array(
157156
'label' => T_('Image Alt text'),

inc/widgets/widgets/_image.widget.php

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

inc/widgets/widgets/_site_logo.widget.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ function get_param_definitions( $params )
140140
),
141141
'height' => array(
142142
'label' => T_('Image height'),
143-
'note' => '',
143+
'note' => T_('Leave blank for auto.'),
144144
'defaultvalue' => '',
145145
'allow_empty' => true,
146146
'size' => 4,
@@ -151,7 +151,6 @@ function get_param_definitions( $params )
151151
),
152152
'size_end_line' => array(
153153
'type' => 'end_line',
154-
'label' => T_('Leave blank for auto.'),
155154
),
156155
'alt' => array(
157156
'label' => T_('Image Alt text'),

0 commit comments

Comments
 (0)