Home › Forums › Calendar Products › Community Events › file upload size in Kilobytes
- This topic has 10 replies, 2 voices, and was last updated 5 years, 7 months ago by karen.
-
AuthorPosts
-
August 17, 2018 at 8:15 am #1599872karenParticipant
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
KarenAugust 20, 2018 at 9:36 am #1601343SkyKeymasterHi 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,
SkyAugust 20, 2018 at 9:54 am #1601358karenParticipantThis 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' ); --
August 21, 2018 at 8:35 am #1602140SkyKeymasterHi 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,
SkySeptember 9, 2018 at 4:28 am #1617031karenParticipantHow do I fix this? See screenshot. I need the actual size in Kilobytes or M would be nice. Thanks!
September 9, 2018 at 4:30 am #1617032karenParticipantA 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.
September 10, 2018 at 10:01 am #1617719SkyKeymasterHi 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,
SkySeptember 10, 2018 at 10:09 am #1617730karenParticipantSky,
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,September 10, 2018 at 10:18 am #1617737SkyKeymasterHi 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,
SkySeptember 10, 2018 at 10:42 am #1617755karenParticipantYES!… thanks for catching that!
September 11, 2018 at 7:19 am #1618443SkyKeymasterAwesome! Glad that fixed it for you.
Please let us know if you have any additional questions or issues in the future.
Thanks,
Sky -
AuthorPosts
- The topic ‘file upload size in Kilobytes’ is closed to new replies.