Modificarea limitei pentru dimensiunea fisierelor uploadate in WordPress

Modificarea limitei pentru dimensiunea fisierelor uploadate in WordPress

1. Modificarea setarilor PHP in cPanel

cPanel > Select PHP Version > Switch to PHP Options > upload_max_filesize = 200M

 

2. Modificarea fisierului php.ini

upload_max_filesize = 200M post_max_size = 200M memory_limit = 200M

 

3. Modificarea fisierului .htaccess

php_value upload_max_filesize 12M
php_value post_max_size 13M
php_value memory_limit 15M

 

4. Modificarea setarilor php din scriptul wp-config.php

ini_set( 'upload_max_size' , '12M' );
ini_set( 'post_max_size', '13M');
ini_set( 'memory_limit', '15M' );

 

5. Utilizarea filtrului WordPress upload_size_limit

/**
 * Filter the upload size limit for non-administrators.
 *
 * @param string $size Upload size limit (in bytes).
 * @return int (maybe) Filtered size limit.
 */
function filter_site_upload_size_limit( $size ) {
    // Set the upload size limit to 10 MB for users lacking the 'manage_options' capability.
    if ( ! current_user_can( 'manage_options' ) ) {
        // 10 MB.
        $size = 1024 * 10000;
    }
    return $size;
}
add_filter( 'upload_size_limit', 'filter_site_upload_size_limit', 20 );

 

Leave a Reply

Your email address will not be published. Required fields are marked *