File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 = '' ;
You can’t perform that action at this time.
0 commit comments