Upload::replace_temp_image( string $str, array|false $allowed_files = false )
Description #
Replace all dummy images found in editor type field.
Parameters #
- $strstring (Required) Content where to replace images.
- $allowed_filesarray | false (Optional) Pass array of allowed file names . Default value: false
Source #
File: lib/form/class-upload.php
public function replace_temp_image( $str, $allowed_files = false ) { $allowed_files = array_map( 'sanitize_file_name', $allowed_files ); // Check for allowed files. $new_files = array(); if ( false !== $allowed_files && $this->value() ) { foreach ( $this->value() as $k => $file ) { if ( in_array( $file['name'], $allowed_files, true ) ) { $new_files[] = $file; } } $this->value = $new_files; } if ( false === $this->uploaded ) { $this->save_uploads(); } return preg_replace_callback( '/({{apimage (.*?)}})/', array( $this, 'file_name_search_replace' ), $str ); }
Expand full source code Collapse full source code View on GitHub: lib/form/class-upload.php:267
Add your comment