file upload size in Kilobytes

Home Forums Calendar Products Community Events file upload size in Kilobytes

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #1599872
    karen
    Participant

    I see you have a code for upload size in Megabytes for community events. I want to limit to Kilobytes. Is that a K or a KB?
    thanks
    Karen

    #1601343
    Sky
    Keymaster

    Hi Karen,

    Can you tell me where you see a field for an upload size limit? I’m not sure where this setting is that you’re referring to.

    In general, a Kilobyte is abbreviated as KB.

    Thanks,
    Sky

    #1601358
    karen
    Participant

    This is Community Events. There is a snippet to add to the Functions.php to limit file upload size to community events. Yes, kb is usually used by your snippet has M for Megabytes so I thought that maybe K for kilobytes would work. Or maybe K is not even legal. Who knows?

    /**
     * The Events Calendar: Community Events: Limit image upload to 1 megabyte.
     *
     * Requires Community Events version 4.5.12 or later.
     *
     * @see Tribe__Events__Community__Main::max_file_size_allowed
     * @see wp_convert_hr_to_bytes()
     *
     * @link https://gist.github.com/cliffordp/03ddb4913adcdb7d2888ef6a7c7841c9 This snippet.
     * @link https://cl.ly/403L0o473b1P 1-minute video demonstrating this snippet works.
     *
     * @return int
     */
    function cliff_ce_max_upload_size() {
    	return wp_convert_hr_to_bytes( ‘1M’ );
    }
    
    add_filter( 'tribe_community_events_max_file_size_allowed', 'cliff_ce_max_upload_size' );
    --
    #1602140
    Sky
    Keymaster

    Hi again

    Thanks for the additional information.

    For this, you can pass either an integer of the number of bytes, or use “m” “g” or “k”. I think it will work with “k” or “kb” in this case.

    See this function documentation: https://developer.wordpress.org/reference/functions/wp_convert_hr_to_bytes/

    Hope that helps!

    Thanks,
    Sky

    #1617031
    karen
    Participant

    How do I fix this? See screenshot. I need the actual size in Kilobytes or M would be nice. Thanks!

    #1617032
    karen
    Participant

    A little more info. when you submit an event or when the event is submitted and it tells you that it cannot upload this file because it does not adhere to the 0B standard.

    #1617719
    Sky
    Keymaster

    Hi again,

    This pulls in whatever value is set in the WordPress settings for “max upload size”. This may be set by your host, a plugin, or even in your htaccess file. In multisite, there is a setting within WordPress, but it looks like you are running a single instance.

    When you go to “add new” media in the admin, do you see a message saying what the upload limit is in the bottom left corner of the upload page? Can you tell me what it says there?

    On my test site I see the following on my Community Events page on the frontend.

    When I adjust the limit, it changes there.

    You might check out this article to get an idea of where this might be set in your case: https://www.cloudways.com/blog/increase-media-file-maximum-upload-size-in-wordpress/

    Thanks,
    Sky

    #1617730
    karen
    Participant

    Sky,
    this just does not make any sense. What does the file upload in the standard wordpress setting have to do with the special setting for community events? Should I not be able to set it separately? And if NOT, what is the point of the addition to the functions.php above to set upload for Community Events. My standard one is set to 50MG but it shows 0 kb. Thanks,

    #1617737
    Sky
    Keymaster

    Hi again,

    I apologize, I wasn’t tracking on that snippet for a second there.

    I tried out the snippet and it is working correctly for me. I did notice that in your code snippet the value inside
    wp_convert_hr_to_bytes() is using fancy quotes, which may be breaking your code.

    Try changing
    return wp_convert_hr_to_bytes( ‘1M’ );

    to
    return wp_convert_hr_to_bytes( '1M' );

    Let me know if that works.

    Thanks,
    Sky

    #1617755
    karen
    Participant

    YES!… thanks for catching that!

    #1618443
    Sky
    Keymaster

    Awesome! Glad that fixed it for you.

    Please let us know if you have any additional questions or issues in the future.

    Thanks,
    Sky

Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘file upload size in Kilobytes’ is closed to new replies.