@@ -111,8 +111,11 @@ function get_param_definitions( $params )
111111 'label ' => T_ ('Fallback image filename ' ),
112112 'note ' => T_ ('If no file was selected. Relative to the root of the selected source. ' ),
113113 'defaultvalue ' => 'logo.png ' ,
114- 'valid_pattern ' => array ( 'pattern ' =>'~^[a-z0-9_\-/][a-z0-9_.\-/]*$~i ' ,
115- 'error ' =>T_ ('Invalid filename. ' ) ),
114+ 'valid_pattern ' => array ( 'pattern ' =>'~^$|^[a-z0-9_\-/][a-z0-9_.\-/]*$~i ' ,
115+ 'error ' =>T_ ('Invalid filename. ' ) ),
116+ // the following is necessary to catch user input value of "<". Otherwise, "<" and succeeding characters
117+ // will translate to an empty string and pass the regex pattern below
118+ 'type ' => 'html_input ' ,
116119 ),
117120 'size_begin_line ' => array (
118121 'type ' => 'begin_line ' ,
@@ -214,8 +217,21 @@ function display( $params )
214217 $ File = & $ FileCache ->get_by_ID ( $ file_ID , false );
215218 }
216219
217- if ( ( $ check_file == 'check ' || $ check_file === '1 ' ) && ( empty ( $ File ) || ! file_exists ( $ File ->get_full_path () ) ) && ! file_exists ( $ image_path .$ this ->disp_params ['logo_file ' ] ) )
218- { // Logo file doesn't exist, Exit here because widget setting requires this:
220+ if ( ! empty ( $ File ) && file_exists ( $ File ->get_full_path () ) )
221+ {
222+ $ image_url = $ File ->get_url ();
223+ }
224+ elseif ( ! empty ( $ this ->disp_params ['logo_file ' ] ) && ( $ check_file == 'none ' || file_exists ( $ image_path .$ this ->disp_params ['logo_file ' ] ) ) )
225+ {
226+ $ image_url .= $ this ->disp_params ['logo_file ' ];
227+ }
228+ else
229+ {
230+ $ image_url = '' ;
231+ }
232+
233+ if ( $ check_file != 'title ' && empty ( $ image_url ) )
234+ {
219235 return true ;
220236 }
221237
@@ -237,12 +253,16 @@ function display( $params )
237253 $ image_attrs .= ' height=" ' .intval ( $ this ->disp_params ['height ' ] ).'" ' ;
238254 }
239255
240- if ( ! empty ( $ File ) )
256+ if ( $ check_file == 'title ' && empty ( $ image_url ) )
257+ { // Logo file doesn't exist, Display a collection title because widget setting requires this:
258+ $ title .= $ Blog ->get ( 'name ' );
259+ }
260+ else
241261 {
242262 // Initialize image attributes:
243263 $ image_attrs = array (
244- 'src ' => $ File -> get_url () ,
245- 'alt ' => empty ( $ this ->disp_params ['alt ' ] ) ? $ Blog ->dget ( 'name ' , 'htmlattr ' ) : $ this ->disp_params ['alt ' ]
264+ 'src ' => $ image_url ,
265+ 'alt ' => empty ( $ this ->disp_params ['alt ' ] ) ? $ Blog ->dget ( 'name ' , 'htmlattr ' ) : $ this ->disp_params ['alt ' ],
246266 );
247267
248268 // Image width:
@@ -254,29 +274,6 @@ function display( $params )
254274
255275 $ title .= '<img ' .get_field_attribs_as_string ( $ image_attrs ).' /> ' ;
256276 }
257- else
258- {
259- if ( $ check_file == 'title ' && ! file_exists ( $ image_path .$ this ->disp_params ['logo_file ' ] ) )
260- { // Logo file doesn't exist, Display a collection title because widget setting requires this:
261- $ title .= $ Blog ->get ( 'name ' );
262- }
263- else
264- {
265- // Initialize image attributes:
266- $ image_attrs = array (
267- 'src ' => $ image_url .$ this ->disp_params ['logo_file ' ],
268- 'alt ' => empty ( $ this ->disp_params ['alt ' ] ) ? $ Blog ->dget ( 'name ' , 'htmlattr ' ) : $ this ->disp_params ['alt ' ],
269- );
270- // Image width:
271- $ image_attrs ['style ' ] = 'width: ' .( empty ( $ this ->disp_params ['width ' ] ) ? 'auto ' : format_to_output ( $ this ->disp_params ['width ' ], 'htmlattr ' ) ).'; ' ;
272- // Image height:
273- $ image_attrs ['style ' ] .= 'height: ' .( empty ( $ this ->disp_params ['height ' ] ) ? 'auto ' : format_to_output ( $ this ->disp_params ['height ' ], 'htmlattr ' ) ).'; ' ;
274- // If no unit is specified in a size, consider the unit to be px:
275- $ image_attrs ['style ' ] = preg_replace ( '/(\d+);/ ' , '$1px; ' , $ image_attrs ['style ' ] );
276-
277- $ title .= '<img ' .get_field_attribs_as_string ( $ image_attrs ).' /> ' ;
278- }
279- }
280277
281278 $ title .= '</a> ' ;
282279
0 commit comments