wp_ajax_media_create_image_subsizes
函数
wp_ajax_media_create_image_subsizes ( No parameters )
- 定义位置
-
-
wp-admin/includes/ajax-actions.php
, line 2474
-
wp-admin/includes/ajax-actions.php
- 引入
- 5.3.0
- 弃用
- –
Ajax handler for creating missing image sub-sizes for just uploaded images.
function wp_ajax_media_create_image_subsizes() {
check_ajax_referer( 'media-form' );
if ( ! current_user_can( 'upload_files' ) ) {
wp_send_json_error( array( 'message' => __( 'Sorry, you are not allowed to upload files.' ) ) );
}
if ( empty( $_POST['attachment_id'] ) ) {
wp_send_json_error( array( 'message' => __( 'Upload failed. Please reload and try again.' ) ) );
}
$attachment_id = (int) $_POST['attachment_id'];
if ( ! empty( $_POST['_wp_upload_failed_cleanup'] ) ) {
// Upload failed. Cleanup.
if ( wp_attachment_is_image( $attachment_id ) && current_user_can( 'delete_post', $attachment_id ) ) {
$attachment = get_post( $attachment_id );
// Created at most 10 min ago.
if ( $attachment && ( time() - strtotime( $attachment->post_date_gmt ) $attachment_id );
} else {
// Media modal and Media Library grid view.
$response = wp_prepare_attachment_for_js( $attachment_id );
if ( ! $response ) {
wp_send_json_error( array( 'message' => __( 'Upload failed.' ) ) );
}
}
// At this point the image has been uploaded successfully.
wp_send_json_success( $response );
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。


