Code Duplication    Length = 36-38 lines in 2 locations

includes/acf/fields/file.php 1 location

@@ 290-325 (lines=36) @@
287
	*  @return	$value (mixed) the modified value
288
	*/
289
	
290
	function format_value( $value, $post_id, $field ) {
291
		
292
		// bail early if no value
293
		if( empty($value) ) {
294
		
295
			return false;
296
			
297
		}
298
		
299
		
300
		// bail early if not numeric (error message)
301
		if( !is_numeric($value) ) {
302
			
303
			return false;
304
				
305
		}
306
		
307
		
308
		// convert to int
309
		$value = intval($value);
310
		
311
		
312
		// format
313
		if( $field['return_format'] == 'url' ) {
314
		
315
			return wp_get_attachment_url($value);
316
			
317
		} elseif( $field['return_format'] == 'array' ) {
318
			
319
			return acf_get_attachment( $value );
320
		}
321
		
322
		
323
		// return
324
		return $value;
325
	}
326
	
327
	
328
	/*

includes/acf/fields/image.php 1 location

@@ 325-362 (lines=38) @@
322
	*  @return	$value (mixed) the modified value
323
	*/
324
	
325
	function format_value( $value, $post_id, $field ) {
326
		
327
		// bail early if no value
328
		if( empty($value) ) {
329
		
330
			return false;
331
			
332
		}
333
		
334
		
335
		// bail early if not numeric (error message)
336
		if( !is_numeric($value) ) {
337
			
338
			return false;
339
				
340
		}
341
		
342
		
343
		// convert to int
344
		$value = intval($value);
345
		
346
		
347
		// format
348
		if( $field['return_format'] == 'url' ) {
349
		
350
			return wp_get_attachment_url( $value );
351
			
352
		} elseif( $field['return_format'] == 'array' ) {
353
			
354
			return acf_get_attachment( $value );
355
			
356
		}
357
		
358
		
359
		// return
360
		return $value;
361
		
362
	}
363
	
364
	
365
	/*