Skip to content

Commit 09ecad9

Browse files
Copilotswissspidy
andcommitted
Simplify STDIN file naming logic and update class documentation
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent 9139445 commit 09ecad9

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

src/Media_Command.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
* Imported file '/home/person/Downloads/image.png' as attachment ID 1753 and attached to post 123 as featured image.
2121
* Success: Imported 1 of 1 images.
2222
*
23+
* # Import an image from STDIN.
24+
* $ curl http://example.com/image.jpg | wp media import -
25+
* Imported file 'STDIN' as attachment ID 1754.
26+
* Success: Imported 1 of 1 items.
27+
*
2328
* # List all registered image sizes
2429
* $ wp media image-size
2530
* +---------------------------+-------+--------+-------+
@@ -339,15 +344,10 @@ public function import( $args, $assoc_args = array() ) {
339344
continue;
340345
}
341346

342-
// Determine the name for the imported file
343-
if ( ! empty( $assoc_args['file_name'] ) ) {
344-
$name = $assoc_args['file_name'];
345-
} else {
346-
// Try to determine file extension from content
347-
$filetype = wp_check_filetype_and_ext( $tempfile, '' );
348-
$ext = ! empty( $filetype['ext'] ) ? '.' . $filetype['ext'] : '';
349-
$name = 'stdin-' . time() . $ext;
350-
}
347+
// Try to determine file extension from content
348+
$filetype = wp_check_filetype_and_ext( $tempfile, '' );
349+
$ext = ! empty( $filetype['ext'] ) ? '.' . $filetype['ext'] : '';
350+
$name = 'stdin-' . time() . $ext;
351351

352352
$orig_filename = 'STDIN';
353353
$file_time = '';

0 commit comments

Comments
 (0)