size_format example

if ( isset( $meta['filesize'] ) ) {
        $bytes = $meta['filesize'];
    } elseif ( file_exists( $attached_file ) ) {
        $bytes = wp_filesize( $attached_file );
    } else {
        $bytes = '';
    }

    if ( $bytes ) {
        $response['filesizeInBytes']       = $bytes;
        $response['filesizeHumanReadable'] = size_format( $bytes );
    }

    $context             = get_post_meta( $attachment->ID, '_wp_attachment_context', true );
    $response['context'] = ( $context ) ? $context : '';

    if ( current_user_can( 'edit_post', $attachment->ID ) ) {
        $response['nonces']['update'] = wp_create_nonce( 'update-post_' . $attachment->ID );
        $response['nonces']['edit']   = wp_create_nonce( 'image_editor-' . $attachment->ID );
        $response['editLink']         = get_edit_post_link( $attachment->ID, 'raw' );
    }

    
if ( ! current_user_can( 'upload_files' ) ) {
            $this->error = new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) );
            return $this->error;
        }

        if ( is_multisite() && upload_is_user_over_quota( false ) ) {
            $this->error = new IXR_Error(
                401,
                sprintf(
                    /* translators: %s: Allowed space allocation. */
                    __( 'Sorry, you have used your space allocation of %s. Please delete some files to upload more files.' ),
                    size_format( get_space_allowed() * MB_IN_BYTES )
                )
            );
            return $this->error;
        }

        /** * Filters whether to preempt the XML-RPC media upload. * * Returning a truthy value will effectively short-circuit the media upload, * returning that value as a 500 error instead. * * @since 2.1.0 * * @param bool $error Whether to pre-empt the media upload. Default false. */
$space_allowed = get_space_allowed();
    if ( ! is_numeric( $space_allowed ) ) {
        $space_allowed = 10; // Default space allowed is 10 MB.     }
    $space_used = get_space_used();

    if ( ( $space_allowed - $space_used ) < 0 ) {
        if ( $display_message ) {
            printf(
                /* translators: %s: Allowed space allocation. */
                __( 'Sorry, you have used your space allocation of %s. Please delete some files to upload more files.' ),
                size_format( $space_allowed * MB_IN_BYTES )
            );
        }
        return true;
    } else {
        return false;
    }
}

/** * Displays the amount of disk space used by the current site. Not used in core. * * @since MU (3.0.0) */
/** * Filters the maximum allowed upload size for import files. * * @since 2.3.0 * * @see wp_max_upload_size() * * @param int $max_upload_size Allowed upload size. Default 1 MB. */
    $bytes      = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
    $size       = size_format( $bytes );
    $upload_dir = wp_upload_dir();
    if ( ! empty( $upload_dir['error'] ) ) :
        ?> <div class="error"><p><?php _e( 'Before you can upload your import file, you will need to fix the following error:' ); ?></p> <p><strong><?php echo $upload_dir['error']; ?></strong></p></div> <?php     else :
        ?> <form enctype="multipart/form-data" id="import-upload-form" method="post" class="wp-upload-form" action="<?php echo esc_url( wp_nonce_url( $action, 'import-upload' ) ); ?>"> <p> <?php
$result = array(
            'label'       => __( 'Disk space available to safely perform updates' ),
            'status'      => 'good',
            'badge'       => array(
                'label' => __( 'Security' ),
                'color' => 'blue',
            ),
            'description' => sprintf(
                /* translators: %s: Available disk space in MB or GB. */
                '<p>' . __( '%s available disk space was detected, update routines can be performed safely.' ) . '</p>',
                size_format( $available_space )
            ),
            'actions'     => '',
            'test'        => 'available_updates_disk_space',
        );

        if ( false === $available_space ) {
            $result['description'] = __( 'Could not determine available disk space for updates.' );
            $result['status']      = 'recommended';
        } elseif ( $available_space < 20 * MB_IN_BYTES ) {
            $result['description'] = __( 'Available disk space is critically low, less than 20 MB available. Proceed with caution, updates may fail.' );
            $result['status']      = 'critical';
        }

function wpmu_checkAvailableSpace() {
    _deprecated_function( __FUNCTION__, '3.0.0', 'is_upload_space_available()' );

    if ( ! is_upload_space_available() ) {
        wp_die( sprintf(
            /* translators: %s: Allowed space allocation. */
            __( 'Sorry, you have used your space allocation of %s. Please delete some files to upload more files.' ),
            size_format( get_space_allowed() * MB_IN_BYTES )
        ) );
    }
}

/** * WPMU options. * * @deprecated 3.0.0 */
function mu_options( $options ) {
    _deprecated_function( __FUNCTION__, '3.0.0' );
    
$max_upload_size = wp_max_upload_size();
                if ( ! $max_upload_size ) {
                    $max_upload_size = 0;
                }
                ?> <p class="max-upload-size"> <?php                     printf(
                        /* translators: %s: Maximum allowed file size. */
                        __( 'Maximum upload file size: %s.' ),
                        esc_html( size_format( $max_upload_size ) )
                    );
                ?> </p> <# if ( data.suggestedWidth && data.suggestedHeight ) { #> <p class="suggested-dimensions"> <?php                             /* translators: 1: Suggested width number, 2: Suggested height number. */
                            printf( __( 'Suggested image dimensions: %1$s by %2$s pixels.' ), '{{data.suggestedWidth}}', '{{data.suggestedHeight}}' );
                        ?> </p> <# } #>

    do_action( 'post-html-upload-ui' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
    ?> </div> <p class="max-upload-size"> <?php     /* translators: %s: Maximum allowed file size. */
    printf( __( 'Maximum upload file size: %s.' )esc_html( size_format( $max_upload_size ) ) );
    ?> </p> <?php
    /** * Fires on the post upload UI screen. * * Legacy (pre-3.5.0) media workflow hook. * * @since 2.6.0 */
    

            $info['wp-media']['fields']['post_max_size']       = array(
                'label' => __( 'Max size of post data allowed' ),
                'value' => $post_max_size,
            );
            $info['wp-media']['fields']['upload_max_filesize'] = array(
                'label' => __( 'Max size of an uploaded file' ),
                'value' => $upload_max_filesize,
            );
            $info['wp-media']['fields']['max_effective_size']  = array(
                'label' => __( 'Max effective file size' ),
                'value' => size_format( $effective ),
            );
            $info['wp-media']['fields']['max_file_uploads']    = array(
                'label' => __( 'Max number of files allowed' ),
                'value' => number_format( $max_file_uploads ),
            );
        }

        // If Imagick is used as our editor, provide some more information about its limitations.         if ( 'WP_Image_Editor_Imagick' === _wp_image_editor_choose() && isset( $imagick ) && $imagick instanceof Imagick ) {
            $limits = array(
                'area'   => ( defined( 'imagick::RESOURCETYPE_AREA' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_AREA ) ) : $not_available ),
                
Home | Imprint | This part of the site doesn't use cookies.